-
Notifications
You must be signed in to change notification settings - Fork 0
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
xp assertions: explicity expect NumPy scalars #2
Conversation
[skip cirrus] [skip circle]
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.
explanation inline!
xp_assert_close(res1, ref1, rtol=2e-16, check_0d=False) | ||
xp_assert_equal(res2, ref2, check_0d=False) | ||
xp_assert_close(res1, ref1, rtol=2e-16) | ||
xp_assert_equal(res2, ref2) | ||
if not is_array_api_strict(xp): | ||
xp_assert_equal(res3, ref3, check_0d=False) | ||
xp_assert_equal(res3, ref3) |
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.
I'm not sure why these had check_0d=False
? Tests pass for me locally without them.
xp_assert_equal(xp.array(0.), xp.array(0.)) | ||
xp_assert_equal(xp.asarray(0.), xp.asarray(0.)) |
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.
Of course this is just cosmetic as this only runs with NumPy, but may as well use the functions that are in the standard.
# as an alternative to `check_0d=False`, explicitly expect scalar | ||
xp_assert_equal(xp.float64(0), xp.asarray(0.)[()]) |
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.
this is the new check I have added
ref = ref[()] if ref.ndim == 0 else ref | ||
xp_assert_close(res, ref, atol=10*eps) |
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.
sometimes this is nonzero-dimensional, so array-api-strict isn't happy with the 0d indexing. That's fine, guard on ndim
.
Rejected |
I'm pretty sure this is preferable since it allows us to keep the 0d check enabled. x-ref scipy#21026