NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.volumeutils.best_write_scale_ftype

Next topic

nibabel.volumeutils.finite_range

Reggie -- the one

nibabel.volumeutils.better_float_of

nibabel.volumeutils.better_float_of(first, second, default=<type 'numpy.float32'>)

Return more capable float type of first and second

Return default if neither of first or second is a float

Parameters:

first : numpy type specifier

Any valid input to np.dtype()`

second : numpy type specifier

Any valid input to np.dtype()`

default : numpy type specifier, optional

Any valid input to np.dtype()`

Returns:

better_type : numpy type

More capable of first or second if both are floats; if only one is a float return that, otherwise return default.

Examples

>>> better_float_of(np.float32, np.float64) is np.float64
True
>>> better_float_of(np.float32, 'i4') is np.float32
True
>>> better_float_of('i2', 'u4') is np.float32
True
>>> better_float_of('i2', 'u4', np.float64) is np.float64
True