Skip to content

Commit 927f7dc

Browse files
committed
FIX: Create test label images with realistic dtypes
1 parent 9b878ba commit 927f7dc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

niworkflows/interfaces/tests/test_nibabel.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ def create_image(data, filename):
6464
@pytest.mark.parametrize(
6565
"affine, data, roi_index, error, err_message",
6666
[
67-
(np.eye(4), np.zeros((2, 2, 2, 2), dtype=int), [1, 0], None, None),
67+
(np.eye(4), np.zeros((2, 2, 2, 2), dtype=np.uint16), [1, 0], None, None),
6868
(
6969
np.eye(4),
70-
np.zeros((2, 2, 3, 2), dtype=int),
70+
np.zeros((2, 2, 3, 2), dtype=np.uint16),
7171
[1, 0],
7272
True,
7373
"Mismatch in image shape",
7474
),
7575
(
7676
bad_affine,
77-
np.zeros((2, 2, 2, 2), dtype=int),
77+
np.zeros((2, 2, 2, 2), dtype=np.uint16),
7878
[1, 0],
7979
True,
8080
"Mismatch in affine",
8181
),
8282
(
8383
np.eye(4),
84-
np.zeros((2, 2, 2, 2), dtype=int),
84+
np.zeros((2, 2, 2, 2), dtype=np.uint16),
8585
[0, 0, 0],
8686
True,
8787
"Overlapping ROIs",
@@ -90,8 +90,8 @@ def create_image(data, filename):
9090
)
9191
def test_merge_rois(tmpdir, create_roi, affine, data, roi_index, error, err_message):
9292
tmpdir.chdir()
93-
roi0 = create_roi(np.eye(4), np.zeros((2, 2, 2, 2), dtype=int), [0, 0])
94-
roi1 = create_roi(np.eye(4), np.zeros((2, 2, 2, 2), dtype=int), [0, 1])
93+
roi0 = create_roi(np.eye(4), np.zeros((2, 2, 2, 2), dtype=np.uint16), [0, 0])
94+
roi1 = create_roi(np.eye(4), np.zeros((2, 2, 2, 2), dtype=np.uint16), [0, 1])
9595
test_roi = create_roi(affine, data, roi_index)
9696

9797
merge = MergeROIs(in_files=[roi0, roi1, test_roi])
@@ -236,7 +236,7 @@ def test_MergeSeries_affines(tmp_path):
236236
os.chdir(str(tmp_path))
237237

238238
files = ['img0.nii.gz', 'img1.nii.gz']
239-
data = np.ones((10, 10, 10), dtype=int)
239+
data = np.ones((10, 10, 10), dtype=np.uint16)
240240
aff = np.eye(4)
241241
nb.Nifti1Image(data, aff, None).to_filename(files[0])
242242
# slightly alter affine
@@ -251,7 +251,7 @@ def test_MergeSeries_affines(tmp_path):
251251

252252

253253
LABEL_MAPPINGS = {5: 1, 6: 1, 7: 2}
254-
LABEL_INPUT = np.arange(8).reshape(2, 2, 2)
254+
LABEL_INPUT = np.arange(8, dtype=np.uint16).reshape(2, 2, 2)
255255
LABEL_OUTPUT = np.asarray([0, 1, 2, 3, 4, 1, 1, 2]).reshape(2, 2, 2)
256256

257257

0 commit comments

Comments
 (0)