Unit test fails with NumPy 2.3.1 but passes with NumPy 1.26.4
Describe the bug
A unit test tests.transforms.test_signal_remove_frequency.TestSignalRemoveFrequencyNumpy.test_correct_parameters_multi_channels_0 fails when using NumPy 2.3.1, but passes when downgraded to NumPy 1.26.4.
To Reproduce
- Create a conda env with:
- monai==1.5.0
- numpy==2.3.1
- torch==2.6.0+cu126
- torchaudio==2.6.0+cu126
- other related packages
- Run
python -m unittest tests.transforms.test_signal_remove_frequency - See test failure AssertionError: Not equal to tolerance rtol=1e-05, atol=0
Expected behavior Tests should pass consistently across supported NumPy versions.
Environment
================================
Printing system config...
================================
System: Linux
Linux version: Ubuntu 24.04.1 LTS
Platform: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.39
Processor: x86_64
Machine: x86_64
Python version: 3.12.11
Process name: python
Command: ['python', '-c', 'import monai; monai.config.print_debug_info()']
Num physical CPUs: 6
Num logical CPUs: 6
Num usable CPUs: 6
CPU usage (%): [6.8, 2.4, 3.1, 3.9, 3.9, 92.2]
CPU freq. (MHz): 3696
Load avg. in last 1, 5, 15 mins (%): [1.3, 0.5, 0.1]
Disk usage (%): 12.5
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 25.0
Available memory (GB): 22.1
Used memory (GB): 2.5
================================
Printing GPU config...
================================
Num GPUs: 1
Has CUDA: True
CUDA version: 12.6
cuDNN enabled: True
NVIDIA_TF32_OVERRIDE: None
TORCH_ALLOW_TF32_CUBLAS_OVERRIDE: None
cuDNN version: 90501
Current device: 0
Library compiled for CUDA architectures: ['sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_90']
GPU 0 Name: NVIDIA GeForce RTX 4060 Ti
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 34
GPU 0 Total memory (GB): 16.0
GPU 0 CUDA capability (maj.min): 8.9
Hi @IamTingTing thanks for point this out. I have created a PR which I think fixes the issue but I'll wait for all tests to pass to see if it works across versions. Please have a look to see if this fixes your issue.
Hi @ericspod thanks for the fix! I’ve tested the PR on my environment with NumPy 2.3.1 and can confirm the unit test now passes.
Has that PR been merged now? Can this issue be closed?
Hi @dzenanz ,thank you for following up. Since the PR is not yet merged, I think it would be better to keep this issue open until the changes are included in main.
We should get #8537 through soon, we're sorting out a CI issue currently.