File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed
Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 2020from .quaternions import fillpositive , quat2mat , mat2quat
2121from . import analyze # module import
2222from .spm99analyze import SpmAnalyzeHeader
23+ from .casting import have_binary128
2324
2425# Needed for quaternion calculation
2526FLOAT32_EPS_3 = - np .finfo (np .float32 ).eps * 3
7677header_dtype = np .dtype (header_dtd )
7778
7879# datatypes not in analyze format, with codes
79- try :
80- _float128t = np .float128
81- except AttributeError :
80+ if have_binary128 ():
81+ # Only enable 128 bit floats if we really have IEEE binary 128 longdoubles
82+ _float128t = np .longdouble
83+ _complex256t = np .longcomplex
84+ else :
8285 _float128t = np .void
83- try :
84- _complex256t = np .complex256
85- except AttributeError :
8686 _complex256t = np .void
8787
8888_dtdefs = ( # code, label, dtype definition, niistring
Original file line number Diff line number Diff line change 1414
1515import numpy as np
1616
17- from ..casting import type_info
17+ from ..casting import type_info , have_binary128
1818from ..tmpdirs import InTemporaryDirectory
1919from ..spatialimages import HeaderDataError
2020from ..affines import from_matvec
@@ -309,6 +309,14 @@ def test_binblock_is_file(self):
309309 hdr .write_to (str_io )
310310 assert_equal (str_io .getvalue (), hdr .binaryblock + ZEROB * 4 )
311311
312+ def test_float128 (self ):
313+ hdr = self .header_class ()
314+ if have_binary128 ():
315+ hdr .set_data_dtype (np .longdouble )
316+ assert_equal (hdr .get_data_dtype ().type , np .longdouble )
317+ else :
318+ assert_raises (HeaderDataError , hdr .set_data_dtype , np .longdouble )
319+
312320
313321class TestNifti1Image (tana .TestAnalyzeImage ):
314322 # Run analyze-flavor spatialimage tests
You can’t perform that action at this time.
0 commit comments