diff --git a/pyproject.toml b/pyproject.toml index c6924538e..f6028b2d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[tool.pytest.ini_options] + collect_ignore = ["setup.py", "benchmark/"] + [tool.black] exclude = ''' /( @@ -34,3 +37,17 @@ ] ignore_errors = true omit = ['tests/*', 'tiatoolbox/__main__.py', '*/utils/env_detection.py'] + +[tool.isort] + profile = "black" + multi_line_output = 3 + line_length = 88 + filter_files = "True" + skip = [".gitignore", "benchmarks/*"] + +[build-system] + requires = ["setuptools"] + build-backend = "setuptools.build_meta" + +[tool.distutils.bdist_wheel] + universal = true diff --git a/setup.cfg b/setup.cfg index 638c5f2ec..3aa3fc992 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,9 +19,6 @@ replace = version: {new_version} # TIAToolbox version search = TOOLBOX_VER: {current_version} replace = TOOLBOX_VER: {new_version} -[bdist_wheel] -universal = 1 - [flake8] exclude = docs, *__init__*, setup.py max-line-length = 88 @@ -30,16 +27,3 @@ spellcheck-targets = comments dictionaries = en_US,python,technical max-cognitive-complexity = 14 max-expression-complexity = 7 - -[aliases] -test = pytest - -[tool:pytest] -collect_ignore = ['setup.py', 'benchmark/'] - -[isort] -profile = black -multi_line_output = 3 -skip_gitignore = True -line_length = 88 -filter_files = True diff --git a/tests/test_wsireader.py b/tests/test_wsireader.py index 1d89baa24..59afacb2a 100644 --- a/tests/test_wsireader.py +++ b/tests/test_wsireader.py @@ -2118,7 +2118,7 @@ def test_ngff_omero_below_min_version(tmp_path): wsireader.WSIReader.open(sample_copy) -def test_ngff_omero_above_max_version(tmp_path): +def test_ngff_omero_above_max_version(tmp_path, caplog): """Test for FileNotSupported when omero version is above maximum.""" sample = _fetch_remote_sample("ngff-1") # Create a copy of the sample @@ -2130,8 +2130,10 @@ def test_ngff_omero_above_max_version(tmp_path): zattrs["omero"]["version"] = "10.0" with open(sample_copy / ".zattrs", "w") as fh: json.dump(zattrs, fh, indent=2) - with pytest.raises(FileNotSupported): + # Check that the warning is logged + with caplog.at_level(logging.WARNING): wsireader.WSIReader.open(sample_copy) + assert "maximum supported version" in caplog.text def test_ngff_multiscales_below_min_version(tmp_path): @@ -2150,7 +2152,7 @@ def test_ngff_multiscales_below_min_version(tmp_path): wsireader.WSIReader.open(sample_copy) -def test_ngff_multiscales_above_max_version(tmp_path): +def test_ngff_multiscales_above_max_version(tmp_path, caplog): """Test for FileNotSupported when multiscales version is above maximum.""" sample = _fetch_remote_sample("ngff-1") # Create a copy of the sample @@ -2162,8 +2164,10 @@ def test_ngff_multiscales_above_max_version(tmp_path): zattrs["multiscales"][0]["version"] = "10.0" with open(sample_copy / ".zattrs", "w") as fh: json.dump(zattrs, fh, indent=2) - with pytest.raises(FileNotSupported): + # Check that the warning is logged + with caplog.at_level(logging.WARNING): wsireader.WSIReader.open(sample_copy) + assert "maximum supported version" in caplog.text def test_ngff_non_numeric_version(tmp_path, monkeypatch): diff --git a/tiatoolbox/wsicore/wsireader.py b/tiatoolbox/wsicore/wsireader.py index f2ecf3920..62d671e45 100644 --- a/tiatoolbox/wsicore/wsireader.py +++ b/tiatoolbox/wsicore/wsireader.py @@ -165,7 +165,7 @@ def is_ngff( max_version, multiscales_versions, ) - return False + return True if len(multiscales_versions) > 1: logger.warning( @@ -189,7 +189,7 @@ def is_ngff( max_version, multiscales_versions, ) - return False + return True return is_zarr(path) @@ -3881,7 +3881,7 @@ def _info(self) -> WSIMeta: ) for level in self.wsi.levels ] - dataset = self.wsi.base_level.datasets[0] + dataset = self.wsi.levels.base_level.datasets[0] # Get pixel spacing in mm from DICOM file and convert to um/px (mpp) mm_per_pixel = dataset.pixel_spacing mpp = (mm_per_pixel.width * 1e3, mm_per_pixel.height * 1e3)