Skip to content

Commit 9ad693c

Browse files
committed
BF: untested windows, PPC float fixes broken
Was returning results of a dict update, which were obviously None, thence crashes loading modules.
1 parent f15eacd commit 9ad693c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

nibabel/casting.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,19 @@ def type_info(np_type):
233233
if vals in ((112, 15, 16), # binary128
234234
(info_64.nmant, info_64.nexp, 8), # float64
235235
(63, 15, 12), (63, 15, 16)): # Intel extended 80
236-
pass # these are OK
237-
elif vals in ((52, 15, 12), # windows float96
238-
(52, 15, 16)): # windows float128?
236+
return ret # these are OK without modification
237+
# The remaining types are longdoubles with bad finfo values. Some we
238+
# correct, others we wait to hear of errors.
239+
# We start with float64 as basis
240+
ret = type_info(np.float64)
241+
if vals in ((52, 15, 12), # windows float96
242+
(52, 15, 16)): # windows float128?
239243
# On windows 32 bit at least, float96 is Intel 80 storage but operating
240244
# at float64 precision. The finfo values give nexp == 15 (as for intel
241245
# 80) but in calculations nexp in fact appears to be 11 as for float64
242-
return type_info(np.float64).update(dict(width=width))
246+
ret.update(dict(width=width))
243247
elif vals == (1, 1, 16) and processor() == 'powerpc': # broken PPC
244-
ret = type_info(np.float64).update(dict(nmant=106, width=width))
248+
ret.update(dict(nmant=106, width=width))
245249
else: # don't recognize the type
246250
raise FloatingError('We had not expected type %s' % np_type)
247251
return ret
@@ -549,7 +553,7 @@ def ok_floats():
549553
Remove longdouble if it has no higher precision than float64
550554
"""
551555
floats = sorted(np.sctypes['float'], key=lambda f : type_info(f)['nmant'])
552-
if best_float() != np.longdouble:
556+
if best_float() != np.longdouble and np.longdouble in floats:
553557
floats.remove(np.longdouble)
554558
return floats
555559

0 commit comments

Comments
 (0)