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

BUG: Fix cast safety and comparisons for zero sized voids #19322

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

seberg
Copy link
Member

@seberg seberg commented Jun 24, 2021

These are more complicated and weird things could happen...
right now, the only "weird" thing is that some sized to unsized
voids casts may be considered as safe when they should not be.

I think this is fine... In general, we need to fix all casts
to a strict interpretation of V0, S0, and U0 and then then
allow "V", "S", and "U" explicitly on the python entry-points

Right now, this is as minimal as I could make it work, it isn't
as minimal as I would like after a release, but here we go...

Closes gh-19305

These are more complicated and weird things could happen...
right now, the only "weird" thing is that some sized to unsized
voids casts may be considered as safe when they should not be.

I think this is fine... In general, we need to fix all casts
to a strict interpretation of V0, S0, and U0 and then then
allow "V", "S", and "U" explicitly on the python entry-points

Right now, this is as minimal as I could make it work, it isn't
as minimal as I would _like_ after a release, but here we go...
@@ -147,6 +147,9 @@ def test_to_void(self):
assert not np.can_cast("U1", "V1")
# Structured to unstructured is just like any other:
assert np.can_cast("d,i", "V", casting="same_kind")
# Unstructured void to unstructured is actually no cast at all:
assert np.can_cast("V3", "V", casting="no")
assert np.can_cast("V0", "V", casting="no")
Copy link
Member Author

Choose a reason for hiding this comment

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

If this is confusing, it is because V is interpreted as the unsized void (or void DType) and not V0 here. You can't use an actual V0 here, but if you could the result would be same-kind.

@charris
Copy link
Member

charris commented Jun 24, 2021

Thanks Sebastian.

@seberg seberg deleted the issue-19305 branch June 24, 2021 16:37
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jun 25, 2021
@charris charris removed this from the 1.21.1 release milestone Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elementwise equality comparison with zero-length void dtype fails on NumPy 1.21
2 participants