Skip to content

Commit 3f82016

Browse files
authored
5425 conda tests (#5426)
Fixes #5425 tested: https://github.com/Project-MONAI/MONAI/actions/runs/3344552788 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Wenqi Li <wenqil@nvidia.com>
1 parent 6e77d57 commit 3f82016

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/test_nifti_rw.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def test_write_2d(self):
157157
writer_obj.set_metadata({"affine": np.diag([1, 1, 1]), "original_affine": np.diag([1.4, 1, 1])})
158158
writer_obj.write(image_name, verbose=True)
159159
out = nib.load(image_name)
160-
np.testing.assert_allclose(out.get_fdata(), [[0, 1, 2], [3.0, 4, 5]])
161-
np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]))
160+
np.testing.assert_allclose(out.get_fdata(), [[0, 1, 2], [3.0, 4, 5]], atol=1e-4, rtol=1e-4)
161+
np.testing.assert_allclose(out.affine, np.diag([1.4, 1, 1, 1]), atol=1e-4, rtol=1e-4)
162162

163163
image_name = os.path.join(out_dir, "test1.nii.gz")
164164
img = np.arange(5).reshape((1, 5))
@@ -168,8 +168,8 @@ def test_write_2d(self):
168168
)
169169
writer_obj.write(image_name, verbose=True)
170170
out = nib.load(image_name)
171-
np.testing.assert_allclose(out.get_fdata(), [[0, 2, 4]])
172-
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 1, 1]))
171+
np.testing.assert_allclose(out.get_fdata(), [[0, 2, 4]], atol=1e-4, rtol=1e-4)
172+
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 1, 1]), atol=1e-4, rtol=1e-4)
173173

174174
def test_write_3d(self):
175175
with tempfile.TemporaryDirectory() as out_dir:
@@ -192,8 +192,8 @@ def test_write_3d(self):
192192
)
193193
writer_obj.write(image_name, verbose=True)
194194
out = nib.load(image_name)
195-
np.testing.assert_allclose(out.get_fdata(), [[[0, 2, 4]]])
196-
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))
195+
np.testing.assert_allclose(out.get_fdata(), [[[0, 2, 4]]], atol=1e-4, rtol=1e-4)
196+
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4)
197197

198198
def test_write_4d(self):
199199
with tempfile.TemporaryDirectory() as out_dir:
@@ -216,8 +216,8 @@ def test_write_4d(self):
216216
)
217217
writer_obj.write(image_name, verbose=True)
218218
out = nib.load(image_name)
219-
np.testing.assert_allclose(out.get_fdata(), [[[[0], [2], [4]]]])
220-
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))
219+
np.testing.assert_allclose(out.get_fdata(), [[[[0], [2], [4]]]], atol=1e-4, rtol=1e-4)
220+
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4)
221221

222222
def test_write_5d(self):
223223
with tempfile.TemporaryDirectory() as out_dir:
@@ -241,8 +241,10 @@ def test_write_5d(self):
241241
writer_obj.set_metadata({"affine": np.diag([1, 1, 1, 3]), "original_affine": np.diag([1.4, 2.0, 2, 3])})
242242
writer_obj.write(image_name, verbose=True)
243243
out = nib.load(image_name)
244-
np.testing.assert_allclose(out.get_fdata(), np.array([[[[[0.0, 2.0]], [[4.0, 5.0]], [[7.0, 9.0]]]]]))
245-
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]))
244+
np.testing.assert_allclose(
245+
out.get_fdata(), np.array([[[[[0.0, 2.0]], [[4.0, 5.0]], [[7.0, 9.0]]]]]), atol=1e-4, rtol=1e-4
246+
)
247+
np.testing.assert_allclose(out.affine, np.diag([1.4, 2, 2, 1]), atol=1e-4, rtol=1e-4)
246248

247249

248250
if __name__ == "__main__":

0 commit comments

Comments
 (0)