Skip to content

test_isdtype #174

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 1 commit into from
Mar 28, 2023
Merged

test_isdtype #174

merged 1 commit into from
Mar 28, 2023

Conversation

honno
Copy link
Member

@honno honno commented Mar 15, 2023

New territory here, but is currently passing for data-apis/array-api-compat#32

@honno honno requested a review from asmeurer March 15, 2023 11:38
@@ -174,6 +175,33 @@ def test_iinfo(dtype):
# TODO: test values


if api_version >= "2022.12":
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how I feel about nesting tests under if api_version like this instead of just skipping them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, doesn't feel good. I (seemingly) have to do this for a test like test_conj because we're using the >=2022.12 feature of Hypothesis xps.complex_dtypes(),

if api_version >= "2022.12":
@given(xps.arrays(dtype=xps.complex_dtypes(), shape=hh.shapes()))
def test_conj(x):
out = xp.conj(x)
ph.assert_dtype("conj", x.dtype, out.dtype)
ph.assert_shape("conj", out.shape, x.shape)
unary_assert_against_refimpl("conj", x, out, operator.methodcaller("conjugate"))

so kinda just did this to be consistent with the pattern. But I think the ultimate goal with test_conj/etc. would be to not use this pattern, so now skipping this test instead in my force-push.

expected = True
break
else:
if dtype == _kind:
Copy link
Member

Choose a reason for hiding this comment

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

This implicitly assumes dtype equality works, meaning if it's broken or incorrect this might not notice. You can see the test I added in my compat PR compare the known value using dtype string names. Maybe it isn't so important here since we also test dtype.__eq__ anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I think we're just out of luck if that's the case. Fortunately this would get checked via a sanity check I wrote in EqualityMapping

if not (key == key): # specifically checking __eq__, not __neq__
raise ValueError(f"Key {key!r} does not have equality with itself")

@asmeurer
Copy link
Member

If this passes my compat PR that sounds good to me.

@honno honno merged commit 2093a12 into data-apis:master Mar 28, 2023
@honno honno deleted the test-isdtype branch February 28, 2024 13:21
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