Skip to content

Commit 9311297

Browse files
committed
TEST: Test int64 warnings for header-less NIfTIs
1 parent c9bb42a commit 9311297

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

nibabel/tests/test_nifti1.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,23 @@ class TestNifti1Pair(tana.TestAnalyzeImage, tspm.ImageScalingMixin):
765765
image_class = Nifti1Pair
766766
supported_np_types = TestNifti1PairHeader.supported_np_types
767767

768+
def test_int64_warning(self):
769+
# Verify that initializing with (u)int64 data and no
770+
# header/dtype info produces a warning
771+
img_klass = self.image_class
772+
hdr_klass = img_klass.header_class
773+
for dtype in (np.int64, np.uint64):
774+
data = np.arange(24, dtype=dtype).reshape((2, 3, 4))
775+
with pytest.warns(FutureWarning):
776+
img_klass(data, np.eye(4))
777+
# No warnings if we're explicit, though
778+
with clear_and_catch_warnings():
779+
warnings.simplefilter("error")
780+
img_klass(data, np.eye(4), dtype=dtype)
781+
hdr = hdr_klass()
782+
hdr.set_data_dtype(dtype)
783+
img_klass(data, np.eye(4), hdr)
784+
768785
def test_none_qsform(self):
769786
# Check that affine gets set to q/sform if header is None
770787
img_klass = self.image_class

0 commit comments

Comments
 (0)