-
Notifications
You must be signed in to change notification settings - Fork 144
Handle NumPy 2.x hash compatibility for WebGL data #584
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
Conversation
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
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.
Rename this to test_braindata.py; hopefully we can add more tests in the future
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.
Renamed to test_braindata.py in bfb0e22 to keep room for additional cases.
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
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.
Pull request overview
This PR fixes a compatibility issue with NumPy ≥2.2 where ndarray.tostring() was removed, causing WebGL view initialization to crash when hashing brain data arrays.
- Updated
_hash()function to usetobytes()instead of the deprecatedtostring()method - Added
np.asarray()coercion to ensure inputs are converted to NumPy arrays before hashing - Added regression test to verify correct hashing behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cortex/dataset/braindata.py | Fixed _hash() function to use tobytes() and added array coercion with np.asarray() for NumPy 2.x compatibility |
| cortex/tests/test_braindata.py | Added test to verify _hash() correctly uses tobytes() and matches expected SHA1 hash output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WebGL data hashing failed on NumPy ≥2.2 because
ndarray.tostring()was removed, causing WebGL view initialization to crash when hashing brain data arrays.tobytes()inbraindata._hashto restore compatibility with modern NumPy.cortex/tests/test_braindata.pythat asserts_hashmatcheshashlib.sha1(array.tobytes())for NumPy arrays.Example:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.