Skip to content

Commit 4630e0d

Browse files
committed
FIX: Maybe
1 parent fbbd801 commit 4630e0d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

nibabel/casting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ def int_to_float(val, flt_type):
495495
# -1
496496
if not isinstance(val, Integral):
497497
val = int(str(val))
498+
val = int(val)
498499
faval = np.longdouble(0)
499500
while val != 0:
500501
f64 = np.float64(val)

nibabel/nifti1.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,15 +2443,11 @@ def _get_analyze_compat_dtype(arr):
24432443
return np.dtype('int16' if arr.max() <= np.iinfo(np.int16).max else 'int32')
24442444

24452445
mn, mx = arr.min(), arr.max()
2446-
if np.can_cast(mn, np.int32) and np.can_cast(mx, np.int32):
2447-
return np.dtype('int32')
2448-
if np.can_cast(mn, np.float32) and np.can_cast(mx, np.float32):
2449-
return np.dtype('float32')
2450-
if isinstance(mn, int) and isinstance(mx, int):
2451-
info = np.finfo('int32')
2446+
if arr.dtype.kind == 'i':
2447+
info = np.iinfo('int32')
24522448
if mn >= info.min and mx <= info.max:
24532449
return np.dtype('int32')
2454-
if isinstance(mn, float) and isinstance(mx, float):
2450+
elif arr.dtype.kind == 'f':
24552451
info = np.finfo('float32')
24562452
if mn >= info.min and mx <= info.max:
24572453
return np.dtype('float32')

nibabel/testing/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def assert_allclose_safely(a, b, match_nans=True, rtol=1e-5, atol=1e-8):
8282
a = a.astype(float)
8383
if b.dtype.kind in 'ui':
8484
b = b.astype(float)
85-
assert np.allclose(a, b, rtol=rtol, atol=atol)
85+
np.testing.assert_allclose(a, b, rtol=rtol, atol=atol)
8686

8787

8888
def assert_arrays_equal(arrays1, arrays2):

0 commit comments

Comments
 (0)