CEA-COSMIC / pysap-mri

MRI external plugin for Python Sparse data Analysis Package
Other
43 stars 18 forks source link

Misuse of numpy.all function in test assertions #137

Open Daval-G opened 2 years ago

Daval-G commented 2 years ago

Several unit tests from mri/tests/test_fourier_adjoint.py (and potentially other files) have wrongly formulated assertions, mostly based on a misuse of the numpy.all function. This, for example was fixed in PR #136:

self.assertFalse((normalized_samples.all() < 0.5 and normalized_samples.all() >= -0.5))

The intended goal is to check if all elements in the array normalized_samples are within the [-0.5; 0.5[ interval. However, normalized_samples.all() just checks if all elements are non-zero, which is statistically true since the test inputs are uniformly random. Following that, the assertion just checks if True < 0.5 and True >= -0.5, which is False and matches the unexpected assertFalse function.

While this example was fixed, several other tests with similar formulations were observed and should be fixed to reflect their intended uses.

chaithyagr commented 2 years ago

@Daval-G did we close this with a PR? Can you please verify if issue is resolved?