nibabel.casting

Utilties for casting numpy values in various ways

Most routines work round some numpy oddities in floating point precision and casting. Others work round numpy casting to and from python ints

Functions

able_int_type(values)

Find the smallest integer numpy type to contain sequence values

as_int(x[, check])

Return python integer representation of number

best_float()

Floating point type with best precision

ceil_exact(val, flt_type)

Return nearest exact integer >= val in float type flt_type

float_to_int(arr, int_type[, nan2zero, infmax])

Convert floating point array arr to type int_type

floor_exact(val, flt_type)

Return nearest exact integer <= val in float type flt_type

floor_log2(x)

floor of log2 of abs(x)

have_binary128()

True if we have a binary128 IEEE longdouble

int_abs(arr)

Absolute values of array taking care of max negative int values

int_to_float(val, flt_type)

Convert integer val to floating point type flt_type

longdouble_lte_float64()

Return True if longdouble appears to have the same precision as float64

longdouble_precision_improved()

True if longdouble precision increased since initial import

ok_floats()

Return floating point types sorted by precision

on_powerpc()

True if we are running on a Power PC platform

shared_range(flt_type, int_type)

Min and max in float type that are >=min, <=max in integer type

type_info(np_type)

Return dict with min, max, nexp, nmant, width for numpy type np_type

ulp([val])

Return gap between val and nearest representable number of same type

Exceptions

CastingError

FloatingError