From 4bf80169a7657ddf2b673dcc3fb31cf256959224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jord=C3=A3o=20Bragantini?= Date: Wed, 7 Aug 2024 16:00:14 -0700 Subject: [PATCH] Fixing pyramid scaling factor (#238) * Fixing pyramid scaling factor * fix pyramid test * fix test again --- iohub/ngff/nodes.py | 2 +- tests/pyramid/test_pyramid.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/iohub/ngff/nodes.py b/iohub/ngff/nodes.py index 6491205c..9624baeb 100644 --- a/iohub/ngff/nodes.py +++ b/iohub/ngff/nodes.py @@ -946,7 +946,7 @@ def initialize_pyramid(self, levels: int) -> None: for tr in transforms: if tr.type == "scale": for i in range(len(tr.scale))[-3:]: - tr.scale[i] /= factor + tr.scale[i] *= factor self.create_zeros( name=str(level), diff --git a/tests/pyramid/test_pyramid.py b/tests/pyramid/test_pyramid.py index 9464f497..1c9ce1bf 100644 --- a/tests/pyramid/test_pyramid.py +++ b/tests/pyramid/test_pyramid.py @@ -18,7 +18,6 @@ def _mock_fov( shape: tuple[int, ...], scale: tuple[float, float, float], ) -> Position: - ds_path = tmp_path / "ds.zarr" channels = [str(i) for i in range(shape[1])] @@ -51,7 +50,6 @@ def _mock_fov( @pytest.mark.parametrize("ndim", [2, 5]) def test_pyramid(tmp_path: Path, ndim: int) -> None: - # not all shapes not divisible by 2 shape = (2, 2, 67, 115, 128)[-ndim:] scale = (2, 0.5, 0.5)[-min(3, ndim) :] @@ -79,7 +77,7 @@ def test_pyramid(tmp_path: Path, ndim: int) -> None: .scale ) assert np.all(level_scale[:-3] == 1) - assert np.allclose(scale / level_scale[-3:], 2**level) + assert np.allclose(level_scale[-3:] / scale, 2**level) assert fov.metadata.multiscales[0].datasets[level].path == str(level)