Skip to content

Commit 1d31f73

Browse files
committed
RF - rename constants for numeric types
Prefering capitals
1 parent 54416e9 commit 1d31f73

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

nibabel/analyze.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@
8484

8585
from .volumeutils import (native_code, swapped_code, make_dt_codes,
8686
calculate_scale, allopen, shape_zoom_affine,
87-
array_to_file, array_from_file, can_cast,
88-
floating_point_types)
87+
array_to_file, array_from_file, can_cast)
8988
from .wrapstruct import WrapStruct
9089
from .spatialimages import (HeaderDataError, HeaderTypeError,
9190
SpatialImage)
@@ -489,7 +488,7 @@ def data_from_fileobj(self, fileobj):
489488
# in-place multiplication and addition on integer types leads to
490489
# integer output types, and disastrous integer rounding.
491490
# We'd like to do inplace if we can, to save memory
492-
is_flt = data.dtype.type in floating_point_types
491+
is_flt = data.dtype.kind in 'fc'
493492
if slope != 1.0:
494493
if is_flt:
495494
data *= slope

nibabel/volumeutils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
default_compresslevel = 1
3232

3333
#: convenience variables for numpy types
34-
floating_point_types = (np.sctypes['complex'] +
35-
np.sctypes['float'])
36-
integer_types = (np.sctypes['int'] + np.sctypes['uint'])
37-
numeric_types = floating_point_types + integer_types
34+
CFLOAT_TYPES = np.sctypes['complex'] + np.sctypes['float']
35+
IUINT_TYPES = np.sctypes['int'] + np.sctypes['uint']
36+
NUMERIC_TYPES = CFLOAT_TYPES + IUINT_TYPES
3837

3938

4039
class Recoder(object):
@@ -799,7 +798,7 @@ def finite_range(arr):
799798
stride_order = np.argsort(arr.strides)[::-1]
800799
sarr = arr.transpose(stride_order)
801800
typ = sarr.dtype.type
802-
if typ in integer_types:
801+
if typ in IUINT_TYPES:
803802
return np.min(sarr), np.max(sarr)
804803
if typ not in np.sctypes['float']:
805804
raise TypeError('Can only handle floats and (u)ints')

0 commit comments

Comments
 (0)