-
Notifications
You must be signed in to change notification settings - Fork 170
Closed
Labels
Description
Parcels version
main
Description
Getting CI failures from our test suite in #2522 and #2529
Lines 141 to 153 in b7d6de8
| def round_and_hash_float_array(arr, decimals=6): | |
| arr = np.round(arr, decimals=decimals) | |
| # Adapted from https://cs.stackexchange.com/a/37965 | |
| h = 1 | |
| for f in arr: | |
| # Mimic Float.floatToIntBits: converts float to 4-byte binary, then interprets as int | |
| float_as_int = struct.unpack("!i", struct.pack("!f", f))[0] | |
| h = 31 * h + float_as_int | |
| # Mimic Java's HashMap hash transformation | |
| h ^= (h >> 20) ^ (h >> 12) | |
| return h ^ (h >> 7) ^ (h >> 4) |
We should have been paying more attention to our warnings, since now in numpy 2.4.2 we have failures :)
Code sample
# test.py
import numpy as np
import struct
struct.pack("!f", np.array([261], dtype="int32"))uv run test.py --with "numpy==2.3.5"
/Users/Hodgs004/coding/repos/parcels/numpy-bug/test.py:4: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
struct.pack("!f", np.array([261], dtype="int32"))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done