-
Notifications
You must be signed in to change notification settings - Fork 45
Test operator special cases #38
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
Conversation
Nice. Why are there additions to non-operator methods here too? Were some tests being omitted previously for some reason? I hope the generate_stubs script wasn't too hard to work with. That code is a bit hairy. |
Oh I see there were several changes in the spec recently. Let me just run generate_stubs on main so that the diff here is easier to read. |
I'm not sure when this started happening, but several atan and atan2 special case tests involving π are failing because they don't compare exactly equal to the given value of π for float32. The spec only requires an approximation, so this should be fixed, but I'm a little curious how I haven't seen this before. |
3bd4dc6
to
d4c5623
Compare
Haha bit challenging at first, but it does all makes sense. Some small areas I could factor out, but IMO the only thing that was difficult to grasp was how
Couldn't reproduce on my machine, though I was out of sync of NumPy upstream or your PR branches. I can explore this but prob worthwhile in a future PR given the awkwardness of reproducing (e.g. building NumPy versions). |
I think it must be a hypothesis random failure that my machine started finding. Probably will catch them if you run |
'__sub__', | ||
'__truediv__', | ||
'__xor__' | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not super important since these are unlikely to change, but can't we extract this list from the spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seemingly not, as there needs to be a way to distinguish standard operators to in-place operators.
This looks good to me. You can merge when you are happy with it. |
d4c5623
to
3e3b166
Compare
Resolves #37. Creates
test_dunder_<op>.py
files for each operator with special cases to test, much like how the elementwise cases are generated.It seems like the only problem with
numpy.array_api
(when running 2000 examples) is in-place addition.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.