We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88480c6 commit 8061909Copy full SHA for 8061909
nibabel/nifti1.py
@@ -2124,13 +2124,15 @@ def set_data_dtype(self, datatype):
2124
>>> img.get_data_dtype() == np.dtype('int64')
2125
True
2126
"""
2127
- # Static aliases
2128
- if datatype == 'mask':
2129
- datatype = 'u1'
2130
- # Dynamic aliases
2131
- elif datatype in ('compat', 'smallest'):
2132
- self._dtype_alias = datatype
2133
- return
+ # Numpy dtype comparison can fail in odd ways, check for aliases only if str
+ if isinstance(datatype, str):
+ # Static aliases
+ if datatype == 'mask':
+ datatype = 'u1'
+ # Dynamic aliases
+ elif datatype in ('compat', 'smallest'):
2134
+ self._dtype_alias = datatype
2135
+ return
2136
2137
self._dtype_alias = None
2138
super().set_data_dtype(datatype)
0 commit comments