-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Fix dtype int vs char inconsistencies + dtype hashing #231
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0861c7
STY: cleanup hashdesc.c to follow our C conventions.
cournape 40e4393
BUG: fix inconsistencies in dtype flag type at the C level.
cournape 3d8da15
BUG: fix #2017 by ignoring type_num in the hash input.
cournape 27a1bb2
BUG: fix flags type when exposed to python.
cournape b301dfd
STY: more C-style tweaks.
cournape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: fix #2017 by ignoring type_num in the hash input.
Since type_num is not considered in PyArray_EquivTypes (for dtype equality comparison), seems reasonable to ignore it for hashing as well.
- Loading branch information
commit 3d8da1540b51060097dea6eb48fe40f5e4a3811f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could test more cases here, although that gets complicated by the various conventions. What happens with float96/float128 and true quad precision?
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 actually more of a regression test than a unit test (for #2017). Do you feel that more unit tests for dtype hashing are needed ? Or just to check the flags member value ?
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.
Mostly it's motivated by my experience that every time I write a complete test it turns up bugs, so I'm trying to push things that way. The test here will do, but it would be nice to make something more complete. If you are pressed for time, and who isn't, this can go in as is. Writing a solid test for this looks to be non-trivial, but another PR with such a test would be welcome.
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 am fine adding new tests (am sprinting at pycon), but I am not sure what kind of tests you had in mind ?
Regarding true quad precision, I don't think we have any platform supporting those yet, or I misunderstand the test you have in mind.
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.
Sun supports quad precision. I think it will show up in the next couple of years.
I'm not sure what tests would be appropriate, maybe a table of known hashes to check against. What about void types and structured types? In some ways this might be like the tests for the random number generators where just the first several values starting with a known seed are tabulated. That serves to make sure that changes don't go unnoticed. If there is a chance that pickles are affected that could be checked also. Can you think of other things that might be useful? I'm no expert here.
How was pycon?
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.
Regarding quad precision, I cannot test this, but I cannot see a reason why it would not work: the hash method use the same attributes for all builtin dtypes.
Right now, I think we have decent coverage of the hashing logic to test the a == b -> hash(a) == hash(b). As for structured types, we already have some tests (look for tests using assert_dtype_equal/assert_dtype_not_equal), as well as for subarray dtypes.
I am not sure we want to hardcode hashes - we do not want to guarantee more than python itself, and given the recent discussion on randomized hashes, they may be even weaker than they are now (http://bugs.python.org/issue13703).
Pycon was nice, quite a few things we need to look at (https://us.pycon.org/2012/schedule/presentation/78/).
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.
Yes, I've been keeping an eye on that, even posted a heads up on the list a while back. Linux Weekly News is a good place to keep an eye on new things like that.