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

Precision issue in TestClipIntensityPercentiles3D #7797

Closed
KumoLiu opened this issue May 23, 2024 · 0 comments · Fixed by #7808
Closed

Precision issue in TestClipIntensityPercentiles3D #7797

KumoLiu opened this issue May 23, 2024 · 0 comments · Fixed by #7808
Labels
bug Something isn't working

Comments

@KumoLiu
Copy link
Contributor

KumoLiu commented May 23, 2024

======================================================================
FAIL: test_soft_clipping_two_sided_0 (tests.test_clip_intensity_percentiles.TestClipIntensityPercentiles3D)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/parameterized/parameterized.py", line 620, in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
  File "/tmp/tmp.NqmlxED7DG/tests/test_clip_intensity_percentiles.py", line 150, in test_soft_clipping_two_sided
    assert_allclose(result, p(expected), type_test="tensor", rtol=1e-4, atol=0)
  File "/tmp/tmp.NqmlxED7DG/tests/utils.py", line 135, in assert_allclose
    np.testing.assert_allclose(actual, desired, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/numpy/testing/_private/utils.py", line 1592, in assert_allclose
    assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/numpy/testing/_private/utils.py", line 862, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Not equal to tolerance rtol=0.0001, atol=0

Mismatched elements: 245760 / 245760 (100%)
Max absolute difference: 0.00060272
Max relative difference: 0.00134147
 x: array([[[[[0.28405, 0.28405, 0.28405, ..., 0.28405, 0.28405, 0.28405],
          [0.28405, 0.28405, 0.28405, ..., 0.28405, 0.28405, 0.28405],
          [0.28405, 0.28405, 0.28405, ..., 0.28405, 0.28405, 0.28405],...
 y: array([[[[[0.2844, 0.2844, 0.2844, ..., 0.2844, 0.2844, 0.2844],
          [0.2844, 0.2844, 0.2844, ..., 0.2844, 0.2844, 0.2844],
          [0.2844, 0.2844, 0.2844, ..., 0.2844, 0.2844, 0.2844],...

----------------------------------------------------------------------
@KumoLiu KumoLiu added the bug Something isn't working label May 27, 2024
KumoLiu added a commit to KumoLiu/MONAI that referenced this issue May 27, 2024
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
ericspod pushed a commit that referenced this issue May 28, 2024
Fixes #7797

### Description
Ensure the same dtype when test to avoid precision issue.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant