Navigation Menu

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

Dtype field ordering for NumPy 1.14 #1837

Merged
merged 2 commits into from Jul 15, 2019
Merged

Conversation

socec
Copy link
Contributor

@socec socec commented Jul 14, 2019

As reported in #1274, the fields are ordered "by position" instead of "by field name" as of NumPy 1.14. This PR sorts the fields by position before registering the dtype.

Perhaps it's worth debating if this goes against what the user wanted. An alternative approach would be to throw a more meaningful exception for Numpy >= 1.14, since we know the expected field order (e.g. "NumPy: Invalid field order while registering dtype, expecting: ..."). This would force the user to correctly order the fields without pybind doing it in the background. But the user would also have to be aware of that change in NumPy 1.14. IMHO the user mostly wants to just register the dtype and the proposed solution will do it across current versions.

When running tests with NumPy 1.14 or later this test exposes the
"invalid buffer descriptor" error reported in pybind#1274.
@aldanor
Copy link
Member

aldanor commented Jul 15, 2019

(Closes #1274 if merged)

@wjakob
Copy link
Member

wjakob commented Jul 15, 2019

This looks good to me, thanks for the fix!

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.

None yet

3 participants