-
Notifications
You must be signed in to change notification settings - Fork 15
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
Use nightly wheels where available to run tests and support NumPy 2.0 #3427
base: main
Are you sure you want to change the base?
Conversation
I think it should be another nightly test, not part of the nightly build of the scipp. Can you add a nightly test action or move it to the end? |
The tests here should fail as the code needs to be updated numpy2.0 The current run is with the nightly builds of the following deps:
|
@@ -671,7 +671,7 @@ def test_arange_datetime_from_str_raises_if_step_has_no_unit(): | |||
|
|||
|
|||
def test_arange_datetime_from_str_raises_given_string_with_timezone(): | |||
with pytest.raises(ValueError, match='timezone'): | |||
with pytest.raises(UserWarning, match='timezone'): |
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.
There are a couple of more tests failing, I'll get back to this later :) |
@@ -897,7 +897,7 @@ def test_bin_with_explicit_lower_precision_drops_rows_outside_domain(): | |||
x = sc.linspace('x', 0.0, 1.0, 3, unit='m', dtype='float32') | |||
da = table.bin(x=x) | |||
size = da.bins.size().sum().value | |||
table.coords['x'].values[0] = 2.0 * np.finfo(np.float32).max | |||
table.coords['x'].values[0] = np.float64(2.0) * np.finfo(np.float32).max |
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.
Type promotion rules have changed: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion
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.
Changes look good. Are we now just waiting for Numba support?
if cls is np.bool: | ||
type_name = 'npbool' | ||
else: | ||
type_name = cls.__name__ |
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 don't like this hack, with numpy 2.0 booleans are back to np.bool
https://numpy.org/devdocs/release/2.0.0-notes.html#changes and hence the name dunder will return bool
, the same as inbuilt python bool
. The hdf5 writer would treat both np.bool
and bool
same. We can look at explicit type instead of the name
dunder but it will be a bit more invasive than this change.
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.
Let's avoid hacks! If using classes directly instead of names is cleaner, do that!
With the changes in this PR and a scipp built with numpy2, mac, linux and windows passes the test suite with python 3.10 Some of the changes here are backward incompatible, but I can update the code to make it work with numpy < 2 too. To make sure we don't distribute broken scipp, we need to release scipp built with numpy2 once numpy makes a 2.0 release (16th June - numpy/numpy#24300 (comment)). We can also cut a release of scipp with an upper pin on numpy if we do want to move to numpy 2 directly. |
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.
Looks good so far. But some tests are still broken.
if cls is np.bool: | ||
type_name = 'npbool' | ||
else: | ||
type_name = cls.__name__ |
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.
Let's avoid hacks! If using classes directly instead of names is cleaner, do that!
I'm not sure if we are testing against nightly builds of packages (where available) of scipp dependencies. Numpy 2.0 will have major breaking changes (which may or may not affect us).