From b7d7623288de328f2e82edcaebcbdfdfc683bd0a Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 28 Oct 2022 10:57:24 +0100 Subject: [PATCH 1/3] temp tests Signed-off-by: Wenqi Li --- .github/workflows/conda.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 98c194f474..196d32c617 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -5,6 +5,9 @@ on: - cron: "0 3 * * *" # at 03:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + push: + branches: + - 5425-conda-tests concurrency: # automatically cancel the previously triggered workflows when there's a newer version From d2fe0f34313e04785ef958a1ef83ac003e6ece1d Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 28 Oct 2022 11:01:18 +0100 Subject: [PATCH 2/3] fixes tests Signed-off-by: Wenqi Li --- tests/test_nifti_rw.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_nifti_rw.py b/tests/test_nifti_rw.py index 31e1de3fe9..6edf53d339 100644 --- a/tests/test_nifti_rw.py +++ b/tests/test_nifti_rw.py @@ -157,8 +157,8 @@ def test_write_2d(self): writer_obj.set_metadata({"affine": np.diag([1, 1, 1]), "original_affine": np.diag([1.4, 1, 1])}) writer_obj.write(image_name, verbose=True) out = nib.load(image_name) - np.testing.assert_allclose(out.get_fdata(), [[0, 1, 2], [3.0, 4, 5]]) - np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1])) + np.testing.assert_allclose(out.get_fdata(), [[0, 1, 2], [3.0, 4, 5]], atol=1e-4, rtol=1e-4) + np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]), atol=1e-4, rtol=1e-4) image_name = os.path.join(out_dir, "test1.nii.gz") img = np.arange(5).reshape((1, 5)) @@ -168,8 +168,8 @@ def test_write_2d(self): ) writer_obj.write(image_name, verbose=True) out = nib.load(image_name) - np.testing.assert_allclose(out.get_fdata(), [[0, 2, 4]]) - np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 1, 1])) + np.testing.assert_allclose(out.get_fdata(), [[0, 2, 4]], atol=1e-4, rtol=1e-4) + np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 1, 1]), atol=1e-4, rtol=1e-4) def test_write_3d(self): with tempfile.TemporaryDirectory() as out_dir: @@ -192,8 +192,8 @@ def test_write_3d(self): ) writer_obj.write(image_name, verbose=True) out = nib.load(image_name) - np.testing.assert_allclose(out.get_fdata(), [[[0, 2, 4]]]) - np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1])) + np.testing.assert_allclose(out.get_fdata(), [[[0, 2, 4]]], atol=1e-4, rtol=1e-4) + np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4) def test_write_4d(self): with tempfile.TemporaryDirectory() as out_dir: @@ -216,8 +216,8 @@ def test_write_4d(self): ) writer_obj.write(image_name, verbose=True) out = nib.load(image_name) - np.testing.assert_allclose(out.get_fdata(), [[[[0], [2], [4]]]]) - np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1])) + np.testing.assert_allclose(out.get_fdata(), [[[[0], [2], [4]]]], atol=1e-4, rtol=1e-4) + np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4) def test_write_5d(self): with tempfile.TemporaryDirectory() as out_dir: @@ -241,8 +241,10 @@ def test_write_5d(self): writer_obj.set_metadata({"affine": np.diag([1, 1, 1, 3]), "original_affine": np.diag([1.4, 2.0, 2, 3])}) writer_obj.write(image_name, verbose=True) out = nib.load(image_name) - np.testing.assert_allclose(out.get_fdata(), np.array([[[[[0.0, 2.0]], [[4.0, 5.0]], [[7.0, 9.0]]]]])) - np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1])) + np.testing.assert_allclose( + out.get_fdata(), np.array([[[[[0.0, 2.0]], [[4.0, 5.0]], [[7.0, 9.0]]]]]), atol=1e-4, rtol=1e-4 + ) + np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4) if __name__ == "__main__": From 809c87e895e20114d0c76130cd614698293bb16f Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Fri, 28 Oct 2022 12:36:23 +0100 Subject: [PATCH 3/3] remove temp tests Signed-off-by: Wenqi Li --- .github/workflows/conda.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 196d32c617..98c194f474 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -5,9 +5,6 @@ on: - cron: "0 3 * * *" # at 03:00 UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - push: - branches: - - 5425-conda-tests concurrency: # automatically cancel the previously triggered workflows when there's a newer version