From 902ff1fe6992d5bf21b8d5fb0797a079953bd32a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 20:46:22 +0100 Subject: [PATCH 01/13] Fix interpolation arg deprecation with np.percentile --- tests/test_tf.py | 2 +- tests/test_torch.py | 2 +- torchstain/torch/utils/percentile.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_tf.py b/tests/test_tf.py index 8edb65a..37b0ee1 100644 --- a/tests/test_tf.py +++ b/tests/test_tf.py @@ -15,7 +15,7 @@ def test_cov(): def test_percentile(): x = np.random.randn(10, 10) p = 20 - p_np = np.percentile(x, p, interpolation='nearest') + p_np = np.percentile(x, p, method='nearest') p_t = torchstain.tf.utils.percentile(x, p) np.testing.assert_almost_equal(p_np, p_t) diff --git a/tests/test_torch.py b/tests/test_torch.py index eb7b60c..b749008 100644 --- a/tests/test_torch.py +++ b/tests/test_torch.py @@ -21,7 +21,7 @@ def test_cov(): def test_percentile(): x = np.random.randn(10, 10) p = 20 - p_np = np.percentile(x, p, interpolation='nearest') + p_np = np.percentile(x, p, method='nearest') p_t = torchstain.torch.utils.percentile(torch.tensor(x), p) np.testing.assert_almost_equal(p_np, p_t) diff --git a/torchstain/torch/utils/percentile.py b/torchstain/torch/utils/percentile.py index 08c28ef..f38e2f0 100644 --- a/torchstain/torch/utils/percentile.py +++ b/torchstain/torch/utils/percentile.py @@ -11,7 +11,7 @@ def percentile(t: torch.Tensor, q: float) -> Union[int, float]: CAUTION: * Needs PyTorch >= 1.1.0, as ``torch.kthvalue()`` is used. * Values are not interpolated, which corresponds to - ``numpy.percentile(..., interpolation="nearest")``. + ``numpy.percentile(..., method="nearest")``. :param t: Input tensor. :param q: Percentile to compute, which must be between 0 and 100 inclusive. From e9869d48ad4fa5da56e314d89cc422d453b21516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 20:53:12 +0100 Subject: [PATCH 02/13] Fix bug in Reinhard numpy implementation --- torchstain/numpy/normalizers/reinhard.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/torchstain/numpy/normalizers/reinhard.py b/torchstain/numpy/normalizers/reinhard.py index 035c49f..d959bc4 100644 --- a/torchstain/numpy/normalizers/reinhard.py +++ b/torchstain/numpy/normalizers/reinhard.py @@ -25,8 +25,7 @@ def fit(self, target): lab = rgb2lab(target) # get summary statistics -# stack_ = np.apply_along_axis(get_mean_std, 1, lab_split(lab)) - stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=lab_split(lab)) + stack_ = np.array([get_mean_std(x) for x in lab_split(lab)]) self.target_means = stack_[:, 0] self.target_stds = stack_[:, 1] @@ -40,8 +39,7 @@ def normalize(self, I): labs = lab_split(lab) # get summary statistics from LAB -# stack_ = np.apply_along_axis(get_mean_std, 1, labs) - stack_ = np.apply_along_axis(get_mean_std, axis=1, arr=labs) + stack_ = np.array([get_mean_std(x) for x in labs]) mus = stack_[:, 0] stds = stack_[:, 1] From 9c04baa01950bba3d0185f19d5e1c2560ea55134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 20:54:58 +0100 Subject: [PATCH 03/13] Upgrade actions/upload-artifact to v4 for all CIs --- .github/workflows/build.yaml | 2 +- .github/workflows/tests_full.yml | 2 +- .github/workflows/tests_quick.yml | 2 +- torchstain/tf/utils/percentile.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d4817d9..dfd35a7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,7 +20,7 @@ jobs: - name: Build wheels run: python setup.py sdist bdist_wheel - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: path: ./dist/* diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index b6d7596..bfd6c02 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -28,7 +28,7 @@ jobs: run: python setup.py bdist_wheel - name: Upload Python wheel - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Python wheel path: ${{github.workspace}}/dist/torchstain-*.whl diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index 4c22ec5..8fb9221 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -25,7 +25,7 @@ jobs: run: python setup.py bdist_wheel - name: Upload Python wheel - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: Python wheel path: ${{github.workspace}}/dist/torchstain-*.whl diff --git a/torchstain/tf/utils/percentile.py b/torchstain/tf/utils/percentile.py index 32f7c67..a6eb742 100644 --- a/torchstain/tf/utils/percentile.py +++ b/torchstain/tf/utils/percentile.py @@ -7,7 +7,7 @@ def percentile(t: tf.Tensor, q: float) -> Union[int, float]: CAUTION: * Values are not interpolated, which corresponds to - ``numpy.percentile(..., interpolation="nearest")``. + ``numpy.percentile(..., method="nearest")``. :param t: Input tensor. :param q: Percentile to compute, which must be between 0 and 100 inclusive. From 105fe3439e1086af1a939e20eaa697b424ef3e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 20:57:08 +0100 Subject: [PATCH 04/13] Bump actions/download-artifact@v4 --- .github/workflows/build.yaml | 2 +- .github/workflows/tests_full.yml | 4 ++-- .github/workflows/tests_quick.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index dfd35a7..35e16ee 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,7 +31,7 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: artifact path: dist diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index bfd6c02..e0ae8e1 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -51,7 +51,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: "Python wheel" @@ -89,7 +89,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: "Python wheel" diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index 8fb9221..9c2cff2 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -43,7 +43,7 @@ jobs: python-version: 3.8 - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: "Python wheel" @@ -69,7 +69,7 @@ jobs: python-version: 3.8 - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: "Python wheel" From 12757daafb476bb318f025f3e5e1edbe00fdf351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 20:59:51 +0100 Subject: [PATCH 05/13] Renamed CIs --- .github/workflows/tests_full.yml | 2 +- .github/workflows/tests_quick.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index e0ae8e1..4f9e353 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -1,4 +1,4 @@ -name: tests +name: Full Tests on: push: diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index 9c2cff2..a873428 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -1,4 +1,4 @@ -name: tests +name: Quick Tests on: push: From 6f2680119e1d63e4b540fd6784c86b80bf3b35b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:01:07 +0100 Subject: [PATCH 06/13] Allow workflow dispatch on test CIs --- .github/workflows/tests_full.yml | 1 + .github/workflows/tests_quick.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index 4f9e353..47136ec 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -7,6 +7,7 @@ on: pull_request: branches: - main + workflow_dispatch: jobs: build: diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index a873428..d721238 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -7,6 +7,7 @@ on: pull_request: branches-ignore: - main + workflow_dispatch: jobs: build: From 075590715125f1f21fda7c090b3eb431df47f4d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:02:40 +0100 Subject: [PATCH 07/13] Bump macos-13 in full tests CI --- .github/workflows/tests_full.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index 47136ec..f9b3064 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -40,7 +40,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ windows-2019, ubuntu-20.04, macos-12 ] + os: [ windows-2019, ubuntu-20.04, macos-13 ] python-version: [ 3.7, 3.8, 3.9 ] tf-version: [2.7.0, 2.8.0, 2.9.0] @@ -71,7 +71,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ windows-2019, ubuntu-20.04, macos-12 ] + os: [ windows-2019, ubuntu-20.04, macos-13 ] python-version: [ 3.6, 3.7, 3.8, 3.9 ] pytorch-version: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0] exclude: From 80af28dc14682b99f2ffc5ed6998de03dce605d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:03:29 +0100 Subject: [PATCH 08/13] Bump actions/setup-python@v4 --- .github/workflows/tests_quick.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index d721238..e07922d 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Set up Python 3.6 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.6 @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 @@ -65,7 +65,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Set up Python 3.8 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 From 7e6f9a03e34cf8fafde81789028cacc18b3d2878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:04:25 +0100 Subject: [PATCH 09/13] Bump actions/checkout@v4 --- .github/workflows/tests_full.yml | 12 ++++++------ .github/workflows/tests_quick.yml | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index f9b3064..53ae96b 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -16,9 +16,9 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') != true steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python 3.6 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.6 @@ -45,9 +45,9 @@ jobs: tf-version: [2.7.0, 2.8.0, 2.9.0] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -83,9 +83,9 @@ jobs: pytorch-version: 1.13.0 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/tests_quick.yml b/.github/workflows/tests_quick.yml index e07922d..b5e62c7 100644 --- a/.github/workflows/tests_quick.yml +++ b/.github/workflows/tests_quick.yml @@ -13,7 +13,7 @@ jobs: build: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python 3.6 uses: actions/setup-python@v4 with: @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: @@ -63,7 +63,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python 3.8 uses: actions/setup-python@v4 with: From 864f20dea9f5e8aeb90a4d0095148198c2f6e6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:32:22 +0100 Subject: [PATCH 10/13] Added mising version bump to build CI --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 35e16ee..26f9a9a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,8 +9,8 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 with: python-version: '3.x' From 9d0876831795176c26311cab06850fe9ab81c22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:32:32 +0100 Subject: [PATCH 11/13] Fix numpy install bug in full tests CI --- .github/workflows/tests_full.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index 53ae96b..bfc3119 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -57,7 +57,7 @@ jobs: name: "Python wheel" - name: Install dependencies - run: pip install tensorflow==${{ matrix.tf-version }} protobuf==3.20.* opencv-python-headless scikit-image pytest + run: pip install tensorflow==${{ matrix.tf-version }} protobuf==3.20.* opencv-python-headless scikit-image pytest "numpy<2" - name: Install wheel run: pip install --find-links=${{github.workspace}} torchstain-* @@ -95,7 +95,7 @@ jobs: name: "Python wheel" - name: Install dependencies - run: pip install torch==${{ matrix.pytorch-version }} torchvision opencv-python-headless scikit-image pytest + run: pip install torch==${{ matrix.pytorch-version }} torchvision opencv-python-headless scikit-image pytest "numpy<2" - name: Install wheel run: pip install --find-links=${{github.workspace}} torchstain-* From 08881ed1e068c6da0c4cc28f68ac45e14b3f3054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 21:37:04 +0100 Subject: [PATCH 12/13] Revert to interpolation arg --- tests/test_tf.py | 2 +- tests/test_torch.py | 2 +- torchstain/tf/utils/percentile.py | 2 +- torchstain/torch/utils/percentile.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_tf.py b/tests/test_tf.py index 37b0ee1..8edb65a 100644 --- a/tests/test_tf.py +++ b/tests/test_tf.py @@ -15,7 +15,7 @@ def test_cov(): def test_percentile(): x = np.random.randn(10, 10) p = 20 - p_np = np.percentile(x, p, method='nearest') + p_np = np.percentile(x, p, interpolation='nearest') p_t = torchstain.tf.utils.percentile(x, p) np.testing.assert_almost_equal(p_np, p_t) diff --git a/tests/test_torch.py b/tests/test_torch.py index b749008..eb7b60c 100644 --- a/tests/test_torch.py +++ b/tests/test_torch.py @@ -21,7 +21,7 @@ def test_cov(): def test_percentile(): x = np.random.randn(10, 10) p = 20 - p_np = np.percentile(x, p, method='nearest') + p_np = np.percentile(x, p, interpolation='nearest') p_t = torchstain.torch.utils.percentile(torch.tensor(x), p) np.testing.assert_almost_equal(p_np, p_t) diff --git a/torchstain/tf/utils/percentile.py b/torchstain/tf/utils/percentile.py index a6eb742..32f7c67 100644 --- a/torchstain/tf/utils/percentile.py +++ b/torchstain/tf/utils/percentile.py @@ -7,7 +7,7 @@ def percentile(t: tf.Tensor, q: float) -> Union[int, float]: CAUTION: * Values are not interpolated, which corresponds to - ``numpy.percentile(..., method="nearest")``. + ``numpy.percentile(..., interpolation="nearest")``. :param t: Input tensor. :param q: Percentile to compute, which must be between 0 and 100 inclusive. diff --git a/torchstain/torch/utils/percentile.py b/torchstain/torch/utils/percentile.py index f38e2f0..08c28ef 100644 --- a/torchstain/torch/utils/percentile.py +++ b/torchstain/torch/utils/percentile.py @@ -11,7 +11,7 @@ def percentile(t: torch.Tensor, q: float) -> Union[int, float]: CAUTION: * Needs PyTorch >= 1.1.0, as ``torch.kthvalue()`` is used. * Values are not interpolated, which corresponds to - ``numpy.percentile(..., method="nearest")``. + ``numpy.percentile(..., interpolation="nearest")``. :param t: Input tensor. :param q: Percentile to compute, which must be between 0 and 100 inclusive. From cb642a525b1959259ab538e88ce395fa99ee6333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Pedersen?= Date: Wed, 8 Jan 2025 22:16:01 +0100 Subject: [PATCH 13/13] Deprecated python 3.6 from tests due to opencv deprecation on macos --- .github/workflows/tests_full.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/tests_full.yml b/.github/workflows/tests_full.yml index bfc3119..057d00f 100644 --- a/.github/workflows/tests_full.yml +++ b/.github/workflows/tests_full.yml @@ -72,15 +72,8 @@ jobs: strategy: matrix: os: [ windows-2019, ubuntu-20.04, macos-13 ] - python-version: [ 3.6, 3.7, 3.8, 3.9 ] + python-version: [ 3.7, 3.8, 3.9 ] pytorch-version: [1.8.0, 1.9.0, 1.10.0, 1.11.0, 1.12.0, 1.13.0] - exclude: - - python-version: 3.6 - pytorch-version: 1.11.0 - - python-version: 3.6 - pytorch-version: 1.12.0 - - python-version: 3.6 - pytorch-version: 1.13.0 steps: - uses: actions/checkout@v4