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

Misuse of numpy.all function in test assertions #137

Open
Daval-G opened this issue Dec 1, 2021 · 1 comment
Open

Misuse of numpy.all function in test assertions #137

Daval-G opened this issue Dec 1, 2021 · 1 comment

Comments

@Daval-G
Copy link
Contributor

Daval-G commented Dec 1, 2021

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
Copy link
Contributor

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

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

No branches or pull requests

2 participants