Skip to content

Filter undefined dtypes in hh.mutually_promotable_dtypes() #34

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

Merged
merged 4 commits into from
Nov 1, 2021

Conversation

honno
Copy link
Member

@honno honno commented Oct 28, 2021

If max_size is not its default value 2, then hh.mutually_promotable_dtypes() before returned undefined dtypes. This PR fixes that. Related to #33.

I now bind xps to the underlying array module mod, instead of the top-level stubbed one. Hypothesis gives nice errors when it encounters erroneous situations due to partial/incorrect Array API adoption, and like with the dtype strategies in hypothesis_helpers.py it will work even if not all dtypes are available.

I also add two test cases, one mocking an array module with undefined dtypes, and one actually testing an array module with undefined dtypes in test_partial_adopters.py. Because of how the codebase is structured, it's pretty awkward to test partial adopters like I had done in Hypothesis, but a liberal use of pytest.mark.skipif() allows us to test how our own strategies work with different array modules.

@@ -1,6 +1,6 @@
from hypothesis.extra.array_api import make_strategies_namespace

from . import _array_module as xp
from ._array_module import mod as xp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be the unstubbed module here, right? Maybe we should del xp so it isn't used elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've aliased this to _xp now to avoid confusion with how we've aliased it everywhere else in the test suite. I could also just use mod blindly, but I think _xp is slightly better at indicating that this indeed is the array module.

@asmeurer
Copy link
Member

I've asked Ralf to give you push access to this repo. You should probably still do PRs for now, but this will let you merge them once they are ready.

This PR looks fine to me. Feel free to merge it once you resolve the conflicts.

@honno honno merged commit 58af424 into data-apis:master Nov 1, 2021
@honno honno deleted the partial-dtypes branch February 8, 2022 10:04
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

Successfully merging this pull request may close these issues.

2 participants