Skip to content
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

test_skymax failing with Numpy 2 #4990

Closed
titodalcanton opened this issue Dec 16, 2024 · 4 comments
Closed

test_skymax failing with Numpy 2 #4990

titodalcanton opened this issue Dec 16, 2024 · 4 comments
Labels

Comments

@titodalcanton
Copy link
Contributor

titodalcanton commented Dec 16, 2024

It looks like CI tests have started picking up Numpy 2, and they fail with this error:

======================================================================
ERROR: test_filtering (__main__.skymax_test_maker.<locals>.Test.test_filtering)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tito/projects/pycbc/pycbc/test/test_skymax.py", line 376, in test_filtering
    det_stat_prec = compute_max_snr_over_sky_loc_stat\
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tito/.conda/envs/py312-numpy2/lib/python3.12/site-packages/pycbc/filter/matchedfilter.py", line 540, in compute_max_snr_over_sky_loc_stat
    idx_p, _ = events.threshold_only(hplus[analyse_slice],
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tito/.conda/envs/py312-numpy2/lib/python3.12/site-packages/pycbc/scheme.py", line 221, in _scheming_function
    return _import_cache[mgr.state][func](*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tito/.conda/envs/py312-numpy2/lib/python3.12/site-packages/pycbc/events/threshold_cpu.py", line 49, in threshold_inline
    arr = numpy.array(series.data, copy=False, dtype=numpy.complex64)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

This specific error though is just me running python test/test_skymax.py from a Conda env with Numpy 2.1.2.

@titodalcanton
Copy link
Contributor Author

I confirm the same command works from a Conda env with Numpy 1.26.4.

@spxiwh
Copy link
Contributor

spxiwh commented Dec 16, 2024

Oh no, this looks like it's probably my fault then if it's in this test!

@spxiwh
Copy link
Contributor

spxiwh commented Dec 16, 2024

I'll try and fix this, but this is almost certainly because I've not used the right dtypes in the test.

@titodalcanton
Copy link
Contributor Author

Fixed by #4991.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants