Skip to content

Commit 6ffea1b

Browse files
committed
FIX: Python types
1 parent 83111ea commit 6ffea1b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

nibabel/nifti1.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,18 +2443,18 @@ 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-
elif isinstance(mn, int) and isinstance(mx, int):
2446+
if isinstance(mn, int) and isinstance(mx, int):
24492447
info = np.finfo('int32')
24502448
if mn >= info.min and mx <= info.max:
24512449
return np.dtype('int32')
2452-
if np.can_cast(mn, np.float32) and np.can_cast(mx, np.float32):
2453-
return np.dtype('float32')
24542450
elif isinstance(mn, float) and isinstance(mx, float):
24552451
info = np.finfo('float32')
24562452
if mn >= info.min and mx <= info.max:
24572453
return np.dtype('float32')
2454+
elif np.can_cast(mn, np.int32) and np.can_cast(mx, np.int32):
2455+
return np.dtype('int32')
2456+
elif np.can_cast(mn, np.float32) and np.can_cast(mx, np.float32):
2457+
return np.dtype('float32')
24582458

24592459
raise ValueError(
24602460
f'Cannot find analyze-compatible dtype for array with dtype={dtype} (min={mn}, max={mx})'

0 commit comments

Comments
 (0)