-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix failing unit-test test_wsireader #7905
Conversation
4954c1b
to
24c0c42
Compare
Hi @hjmjohnson, thanks for the PR, could you please show more details when will the test failed such a small piece of code and also include the test case in the unittests? Thanks! |
This is the failing unit test output from the original code:
I am trying to get full passing of all the monai tests on my computer, and these are the failures I came across. |
Conversion of units when the unit if '' caused the test to fail. FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - ValueError: Currently, it only supports length conversion but `` is given. FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - AttributeError: 'ConvertUnits' object has no attribute 'conversion_factor' Signed-off-by: Hans Johnson <hans-johnson@uiowa.edu>
git checkout dev
git reset origin/dev --hard
pytest -k tiff ============================================================================================= FAILURES =============================================================================================
____________________________________________ TestTiffFile.test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff ____________________________________________
a = (<tests.test_wsireader.TestTiffFile testMethod=test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff>,), kw = {}
@wraps(func)
def standalone_func(*a, **kw):
> return func(*(a + p.args), **p.kwargs, **kw)
.venv/lib/python3.12/site-packages/parameterized/parameterized.py:620:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_wsireader.py:593: in test_resolution_mpp
mpp = reader.get_mpp(img_obj, level)
monai/data/wsi_reader.py:604: in get_mpp
return self.reader.get_mpp(wsi, level)
monai/data/wsi_reader.py:1105: in get_mpp
convert_to_micron = ConvertUnits(unit, "micrometer")
monai/utils/misc.py:808: in __init__
self.input_unit, input_base = self._get_valid_unit_and_base(input_unit)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <monai.utils.misc.ConvertUnits object at 0x79d5f3340380>, unit = ''
def _get_valid_unit_and_base(self, unit):
unit = str(unit).lower()
if unit in self.imperial_unit_of_length:
return unit, "meter"
for base_unit in self.base_units:
if unit.endswith(base_unit):
return unit, base_unit
> raise ValueError(f"Currently, it only supports length conversion but `{unit}` is given.")
E ValueError: Currently, it only supports length conversion but `` is given.
monai/utils/misc.py:826: ValueError |
e0c391f
to
f2d4f1a
Compare
/build |
Fixes #7918 ### Description The main issue is that enum is expressed differently between different pythons Related PR: #7905 ### 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>
Conversion of units when the unit if '' caused the test to fail.
FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - ValueError: Currently, it only supports length conversion but `` is given.
FAILED tests/test_wsireader.py::TestTiffFile::test_resolution_mpp_0__home_johnsonhj_src_MONAI_tests_testing_data_temp_wsi_generic_tiff_tiff - AttributeError: 'ConvertUnits' object has no attribute 'conversion_factor'
Description
Fixes a failing test.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.