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

Try to fix test_skymax on Numpy 2 #4991

Merged
merged 5 commits into from
Dec 16, 2024

Conversation

titodalcanton
Copy link
Contributor

@titodalcanton titodalcanton commented Dec 16, 2024

This is an attempt at fixing #4990.

I am assuming compute_max_snr_over_sky_loc_stat() wants the input arrays to be in single precision for speed/memory considerations.

In my local tests, this will still fail because the results differ from the expected values by 1e-6 or less, so we may have to update the reference values.

test/test_skymax.py Outdated Show resolved Hide resolved
Copy link
Contributor

@spxiwh spxiwh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not worth having the test suite failing over, so I approve any patch that just gets this working again.

It's possible dynamic range stuff will make the simple fix not work unless dynamic range is applied.

It might also make more sense to just cast to complex64 at the 3 lines where we do load_frequencyseries

@titodalcanton
Copy link
Contributor Author

Looks like I need to tell assertAlmostEqual() to be less strict. Are we content with 5 decimal places?

test/test_skymax.py Outdated Show resolved Hide resolved
@titodalcanton titodalcanton requested a review from spxiwh December 16, 2024 13:50
@titodalcanton
Copy link
Contributor Author

The inspiral example is also failing:

>> [Mon Dec 16 14:10:41 UTC 2024] Compressing template bank
Traceback (most recent call last):
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/lib/python3.11/site-packages/pycbc/scheme.py", line 221, in _scheming_function
    return _import_cache[mgr.state][func](*args, **kwds)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
KeyError: <function inline_linear_interp at 0x7f8b597c1580>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/bin/pycbc_compress_bank", line 191, in <module>
    hcompressed = compress.compress_waveform(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/lib/python3.11/site-packages/pycbc/waveform/compress.py", line 237, in compress_waveform
    hdecomp = fd_decompress(comp_amp, comp_phase, sample_points,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/lib/python3.11/site-packages/pycbc/waveform/compress.py", line 441, in fd_decompress
    inline_linear_interp(amp, phase, sample_frequencies, out,
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/lib/python3.11/site-packages/pycbc/scheme.py", line 238, in _scheming_function
    return schemed_fn(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/pycbc/pycbc/.tox/py-search/lib/python3.11/site-packages/pycbc/waveform/decompress_cpu.py", line 38, in inline_linear_interp
    amp = numpy.array(amp, copy=False, dtype=rprec)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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.

@GarethCabournDavies I think this is what you were describing on Slack? If you have a fix, could you push it here?

@spxiwh
Copy link
Contributor

spxiwh commented Dec 16, 2024

The decompress block of code is more important than the skymax test code ... We should check whether a copy should be being done there.

This is Gareth's proposed fix. I think there are optimization improvement possibilities, but the *real* fix is not to generate compressed waveforms with different precision to what you will use when decompressing.
@spxiwh
Copy link
Contributor

spxiwh commented Dec 16, 2024

I applied Gareth's proposed fix here

@titodalcanton titodalcanton merged commit bad3da2 into gwastro:master Dec 16, 2024
28 of 29 checks passed
@titodalcanton titodalcanton deleted the fix-test-skymax branch December 18, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants