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

test_image_filter test error #6622

Closed
wyli opened this issue Jun 18, 2023 · 1 comment · Fixed by #6624
Closed

test_image_filter test error #6622

wyli opened this issue Jun 18, 2023 · 1 comment · Fixed by #6624
Assignees
Labels
bug Something isn't working

Comments

@wyli
Copy link
Contributor

wyli commented Jun 18, 2023

Describe the bug
https://github.com/Project-MONAI/MONAI/actions/runs/5301487274/jobs/9595795019

======================================================================
ERROR: test_init_from_array (tests.test_image_filter.TestImageFilter)
Test init with custom filter and assert wrong filter shape throws an error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/MONAI/MONAI/tests/test_image_filter.py", line 77, in test_init_from_array
    _ = ImageFilter(np.ones((3, 3)))
  File "/home/runner/work/MONAI/MONAI/monai/transforms/utility/array.py", line 1589, in __init__
    self._check_kwargs_are_present(filter, **kwargs)
  File "/home/runner/work/MONAI/MONAI/monai/transforms/utility/array.py", line 1645, in _check_kwargs_are_present
    if filter == "gauss" and "sigma" not in kwargs.keys():
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

----------------------------------------------------------------------
@wyli wyli added the bug Something isn't working label Jun 18, 2023
@mingxin-zheng mingxin-zheng self-assigned this Jun 19, 2023
@mingxin-zheng
Copy link
Contributor

This could be caused by if it is acceptable for numpy to do a comparison as below:

python -c "import numpy as np; filter = np.ones((3, 3)); bool(filter == 'gauss')"

It works on 1.22.2(Linux), but fails on 1.25.0(Mac) for me

wyli pushed a commit that referenced this issue Jun 19, 2023
Fixes #6622 .

### Description

Add type check to avoid comparing a np.array with a string

### 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).
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [x] In-line docstrings updated.

---------

Signed-off-by: Mingxin Zheng <mingxinz@nvidia.com>
Signed-off-by: Mingxin <18563433+mingxin-zheng@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.

2 participants