Skip to content

Make two_mutual_arrays accept a dtypes strategy as input #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
asmeurer opened this issue Oct 27, 2021 · 5 comments
Closed

Make two_mutual_arrays accept a dtypes strategy as input #33

asmeurer opened this issue Oct 27, 2021 · 5 comments

Comments

@asmeurer
Copy link
Member

two_mutual_arrays accepts a list of dtype objects rather than a strategy for generating dtypes. This is somewhat annoying, as everything else uses the dtypes strategies.

A issue with this is that it currently ignores the filtering that is done in the dtype strategies. This makes any test using it fail in pytorch, which doesn't have uint8.

If we can make it accept a dtypes strategy, that would be great. We may just need to have an internal mapping of dtype strategies to promotable dtype strategies. Or maybe we can just draw a dtype then draw another dtype that is promotable compatible with it.

@asmeurer
Copy link
Member Author

Actually it looks like torch fails because it doesn't accept an integer argument to full, only a tuple. If you patch this in hypothesis to pass in a tuple, it fails for other reasons (torch.equal doesn't return an array). I think there is a torch branch somewhere that has better array API support that we should be testing against.

@honno
Copy link
Member

honno commented Oct 28, 2021

So yeah, two_mutual_arrays does already infact filter dtypes. However I realised the underlying mutually_promotable_dtypes() strategy doesn't filter them when max_size>2 (e.g. in some type promotion tests), so that should be fixed in #34.

@honno honno closed this as completed Nov 1, 2021
@asmeurer
Copy link
Member Author

asmeurer commented Nov 1, 2021

Let's leave this open for making two_mutual_arrays accept a strategy as input. It's something that confuses me almost every time I run into it, so it would be good to change it if at all possible.

@asmeurer asmeurer changed the title dtype filtering not enabled for two_mutual_arrays Make two_mutual_arrays accept a dtypes strategy as input Nov 1, 2021
@honno
Copy link
Member

honno commented Nov 3, 2021

Hmm, so I can't figure out how to do this nicely. Both the dtype strategies in hypother_helpers.py and in xps.* return generic strategies with seemingly no way (definitely not public) to distinguish between them (and thus map them to their respective dtype objects).

I wrote #36 at least to raise a consistent error.

@honno honno reopened this Nov 3, 2021
@honno
Copy link
Member

honno commented Jan 18, 2022

I still don't think this is feasible/worth doing, and hopefully my custom error and more experience mitigates the problem you were having.

@honno honno closed this as completed Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants