-
Notifications
You must be signed in to change notification settings - Fork 249
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
Support for NumPy 2.0 in Neo Core #1490
Changes from all commits
a50e343
f9fb7ec
5cf94d4
9f0c35e
dec7667
088a26b
5b5c6c0
24f0e63
3bcbe1c
a22c61b
5dc0dc8
119e715
b27f880
c9113f6
11d9d72
0160830
10605e3
559b739
34771c7
08d9a2e
18cf5ea
f36daa8
8e6c3d4
b67684b
7154a18
8df5dae
d360787
12cdec9
b6d6bb8
a3b753b
2743cdf
f4545c2
4b0fc8e
7d83da0
5930673
d8edd68
5209596
9a1962b
7449082
b078766
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,6 +313,10 @@ def test__create_from_quantity_array(self): | |
|
||
def test__create_from_quantity_array_with_dtype(self): | ||
times = np.arange(10, dtype="f4") * pq.ms | ||
# this step is required for NumPy 2.0 which now casts to float64 in the case either value/array | ||
# is float64 even if not necessary | ||
# https://numpy.org/devdocs/numpy_2_0_migration_guide.html | ||
times = times.astype(dtype="f4") | ||
Comment on lines
315
to
+319
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on discussion with Sam my comment may not have been clear enough. The problem is that |
||
t_start = 0.0 * pq.s | ||
t_stop = 12.0 * pq.ms | ||
train1 = SpikeTrain(times, t_start=t_start, t_stop=t_stop) | ||
|
@@ -343,6 +347,10 @@ def test__create_from_quantity_array_no_start_stop_units(self): | |
|
||
def test__create_from_quantity_array_no_start_stop_units_with_dtype(self): | ||
times = np.arange(10, dtype="f4") * pq.ms | ||
# this step is required for NumPy 2.0 which now casts to float64 in the case either value/array | ||
# is float64 even if not necessary | ||
# https://numpy.org/devdocs/numpy_2_0_migration_guide.html | ||
times = times.astype(dtype="f4") | ||
t_start = 0.0 | ||
t_stop = 12.0 | ||
train1 = SpikeTrain(times, t_start=t_start, t_stop=t_stop) | ||
|
@@ -1143,7 +1151,7 @@ def test_merge_multiple(self): | |
expected *= time_unit | ||
sorting = np.argsort(expected) | ||
expected = expected[sorting] | ||
np.testing.assert_array_equal(result.times, expected) | ||
np.testing.assert_array_equal(result.times.magnitude, expected.magnitude) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is necessary because as of numpy 2.0 because numpy assert_array_equal actually checks that the quantities are the same which leads to a units issue. If someone else understands this better please post here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is annoying @apdavison any comments ? |
||
|
||
# Make sure array annotations are merged correctly | ||
self.assertTrue("label" not in result.array_annotations) | ||
|
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.
only actual change to code base. numpy 2.0 returns this as a
np.str_
thing rather than as the actual string. Usingset
instead ofnp.unique
returns the string both >2.0 and < 2.0 for NumPy. Maybe a slight performance hit, but probably not too bad since the annotations should be small either way and this is in a list and not array.