Skip to content
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

Make special case tests only use relevant arrays #40

Closed
honno opened this issue Nov 10, 2021 · 1 comment
Closed

Make special case tests only use relevant arrays #40

honno opened this issue Nov 10, 2021 · 1 comment

Comments

@honno
Copy link
Member

honno commented Nov 10, 2021

Right now we generate arrays irrelevant to test cases, e.g. arrays with no NaNs in a test case about NaN behaviour. A low-priority thing is to generate test cases which are relevant to the test case (either by xps.arrays(..., elements={...}) or xps.arrays(...).filter(...)). Probably requires some significant reworking of generate_stubs.py.

To quote myself from #38:

It seems like the only problem with numpy.array_api (when running 2000 examples) is in-place addition.

>>> x1 = xp.asarray(-0.0)
>>> x1
Array(-0., dtype=float64)
>>> x2 = xp.asarray(-0.0)
>>> xp.add(x1, x2)
Array(-0., dtype=float64)
>>> x1 + x2
Array(-0., dtype=float64)
>>> x1 += x2
>>> x1
Array(0., dtype=float64)  # not negative 0, like it is with xp.add() and __add__()

Interestingly I had to run like 200 examples to get this error consistently. Something for the future would be to filter strategies from the @given() level so that only arrays with NaNs/infs/whateverproperty-we're-testing are generated, which would mitigate this problem.

@honno
Copy link
Member Author

honno commented May 10, 2022

Resolved by #104

@honno honno closed this as completed May 10, 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

1 participant