From 0eb4f6f1edfe1b1412d1b81e7e49ff9e1d7a792a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Thu, 5 Dec 2024 21:02:19 +0000 Subject: [PATCH] Add lower bounds to dependencies (#1246) * Add lower bounds to dependencies * Add all lower bounds * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add bounds in test dependencies * Fix Ruff error * Add lower bound for packaging --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- pyproject.toml | 39 ++++++++++--------- tests/data/test_io.py | 1 + .../test_histogram_standardization.py | 6 ++- .../preprocessing/test_to_canonical.py | 1 + 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a5131946..8eaf3311 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,23 +37,25 @@ classifiers = [ keywords = ["medical", "image processing", "pytorch", "augmentation", "mri"] requires-python = ">=3.9,<3.13" dependencies = [ - "deprecated", - "humanize", - "nibabel", - "numpy>=1.15", - "scipy", - "simpleitk!=2.0.*,!=2.1.1.1", - "torch>=1.1", - "tqdm", - "typer", + "deprecated>=1.2", + "humanize>=0.1", + "nibabel>=3", + "numpy>=1.20", + "packaging>=20", + "rich>=10", + "scipy>=1.7", + "simpleitk >=1.3, !=2.0.*, !=2.1.1.1", + "torch>=1.9", + "tqdm>=4.40", + "typer>=0.1", ] [project.optional-dependencies] csv = [ - "pandas", + "pandas>=1", ] plot = [ - "matplotlib", + "matplotlib>=3.4", ] [project.scripts] @@ -74,7 +76,8 @@ dev = [ { include-group = "maintain" }, { include-group = "test" }, "ipykernel", - "ruff", + "ruff>0.0.40", + "ipywidgets", ] doc = [ "einops", @@ -91,13 +94,13 @@ maintain = [ "pre-commit-uv", ] test = [ - "coverage", - "mypy", - "parameterized", - "pillow", - "pytest", + "coverage>=5", + "mypy>=0.800", + "parameterized>=0.7", + "pillow>=8", + "pytest>=5", "pytest-cov", - "pytest-sugar", + "pytest-sugar>=0.10", "tox-uv", "types-deprecated", ] diff --git a/tests/data/test_io.py b/tests/data/test_io.py index d3c63429..0128bc79 100644 --- a/tests/data/test_io.py +++ b/tests/data/test_io.py @@ -159,6 +159,7 @@ def test_write_nd_with_a_read_it_with_b(save_lib, load_lib, dims): tensor.squeeze(), loaded_tensor.squeeze(), msg=f'Save lib: {save_lib}; load lib: {load_lib}; dims: {dims}', + check_stride=False, ) TorchioTestCase.assert_tensor_equal(affine, loaded_affine) diff --git a/tests/transforms/preprocessing/test_histogram_standardization.py b/tests/transforms/preprocessing/test_histogram_standardization.py index 425731d3..e4a610b3 100644 --- a/tests/transforms/preprocessing/test_histogram_standardization.py +++ b/tests/transforms/preprocessing/test_histogram_standardization.py @@ -1,6 +1,7 @@ import numpy as np import pytest import torch +from packaging.version import Version from torchio import LabelMap from torchio import ScalarImage @@ -80,7 +81,10 @@ def test_with_saved_dict(self): landmarks_dict = {'image': landmarks} landmarks_path = self.dir / 'landmarks_dict.pth' torch.save(landmarks_dict, landmarks_path) - landmarks_dict = torch.load(landmarks_path, weights_only=False) + kwargs = {} + if Version(torch.__version__) >= Version('1.13'): + kwargs['weights_only'] = False + landmarks_dict = torch.load(landmarks_path, **kwargs) transform = HistogramStandardization(landmarks_dict) transform(self.dataset[0]) diff --git a/tests/transforms/preprocessing/test_to_canonical.py b/tests/transforms/preprocessing/test_to_canonical.py index a32be9bb..4bdd0aa2 100644 --- a/tests/transforms/preprocessing/test_to_canonical.py +++ b/tests/transforms/preprocessing/test_to_canonical.py @@ -28,6 +28,7 @@ def test_las_to_ras(self): self.assert_tensor_almost_equal( transformed.t1.data, torch.from_numpy(array_flip), + check_stride=False, ) fixture = np.eye(4)