/
usr
/
lib64
/
python2.6
/
site-packages
/
numpy
/
core
/
/usr/lib64/python2.6/site-packages/numpy/core
mkdir
upload
Name
Size
Mode
Actions
include/
-
0755
rm
lib/
-
0755
rm
tests/
-
0755
rm
arrayprint.py
16812
0644
edit
dl
rm
arrayprint.pyc
15601
0644
edit
dl
rm
arrayprint.pyo
15601
0644
edit
dl
rm
defchararray.py
69952
0644
edit
dl
rm
defchararray.pyc
78326
0644
edit
dl
rm
defchararray.pyo
78326
0644
edit
dl
rm
defmatrix.py
28094
0644
edit
dl
rm
defmatrix.pyc
30970
0644
edit
dl
rm
defmatrix.pyo
30970
0644
edit
dl
rm
fromnumeric.py
71135
0644
edit
dl
rm
fromnumeric.pyc
75079
0644
edit
dl
rm
fromnumeric.pyo
75079
0644
edit
dl
rm
function_base.py
5201
0644
edit
dl
rm
function_base.pyc
5569
0644
edit
dl
rm
function_base.pyo
5569
0644
edit
dl
rm
generate_numpy_api.py
6444
0644
edit
dl
rm
generate_numpy_api.pyc
6202
0644
edit
dl
rm
generate_numpy_api.pyo
6141
0644
edit
dl
rm
getlimits.py
8790
0644
edit
dl
rm
getlimits.pyc
10068
0644
edit
dl
rm
getlimits.pyo
10068
0644
edit
dl
rm
info.py
4635
0644
edit
dl
rm
info.pyc
4806
0644
edit
dl
rm
info.pyo
4806
0644
edit
dl
rm
machar.py
10658
0644
edit
dl
rm
machar.pyc
8694
0644
edit
dl
rm
machar.pyo
8694
0644
edit
dl
rm
memmap.py
9301
0644
edit
dl
rm
memmap.pyc
9534
0644
edit
dl
rm
memmap.pyo
9534
0644
edit
dl
rm
multiarray.so
584824
0755
edit
dl
rm
multiarray_tests.so
13008
0755
edit
dl
rm
numeric.py
68280
0644
edit
dl
rm
numeric.pyc
72033
0644
edit
dl
rm
numeric.pyo
72033
0644
edit
dl
rm
numerictypes.py
25088
0644
edit
dl
rm
numerictypes.pyc
24189
0644
edit
dl
rm
numerictypes.pyo
24144
0644
edit
dl
rm
records.py
26838
0644
edit
dl
rm
records.pyc
24437
0644
edit
dl
rm
records.pyo
24437
0644
edit
dl
rm
scalarmath.so
164928
0755
edit
dl
rm
scons_support.py
8352
0644
edit
dl
rm
scons_support.pyc
9342
0644
edit
dl
rm
scons_support.pyo
9342
0644
edit
dl
rm
setup.py
32450
0644
edit
dl
rm
setup.pyc
23292
0644
edit
dl
rm
setup.pyo
23292
0644
edit
dl
rm
setupscons.py
4516
0644
edit
dl
rm
setupscons.pyc
4087
0644
edit
dl
rm
setupscons.pyo
4087
0644
edit
dl
rm
setup_common.py
10069
0644
edit
dl
rm
setup_common.pyc
8353
0644
edit
dl
rm
setup_common.pyo
8353
0644
edit
dl
rm
shape_base.py
6294
0644
edit
dl
rm
shape_base.pyc
7123
0644
edit
dl
rm
shape_base.pyo
7123
0644
edit
dl
rm
umath.so
325904
0755
edit
dl
rm
umath_tests.so
12192
0755
edit
dl
rm
_dotblas.so
20712
0755
edit
dl
rm
_internal.py
10368
0644
edit
dl
rm
_internal.pyc
10870
0644
edit
dl
rm
_internal.pyo
10870
0644
edit
dl
rm
_mx_datetime_parser.py
33252
0644
edit
dl
rm
_mx_datetime_parser.pyc
29029
0644
edit
dl
rm
_mx_datetime_parser.pyo
29029
0644
edit
dl
rm
_sort.so
90736
0755
edit
dl
rm
__init__.py
983
0644
edit
dl
rm
__init__.pyc
1261
0644
edit
dl
rm
__init__.pyo
1261
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/site-packages/numpy/core/getlimits.py
(8790B)
""" Machine limits for Float32 and Float64 and (long double) if available... """ __all__ = ['finfo','iinfo'] from numpy.core.machar import MachAr from numpy.core import numeric from numpy.core import numerictypes as ntypes from numpy.core.numeric import array def _frz(a): """fix rank-0 --> rank-1""" if a.ndim == 0: a.shape = (1,) return a _convert_to_float = { ntypes.csingle: ntypes.single, ntypes.complex_: ntypes.float_, ntypes.clongfloat: ntypes.longfloat } class finfo(object): """ finfo(dtype) Machine limits for floating point types. Attributes ---------- eps : floating point number of the appropriate type The smallest representable number such that ``1.0 + eps != 1.0``. epsneg : floating point number of the appropriate type The smallest representable number such that ``1.0 - epsneg != 1.0``. iexp : int The number of bits in the exponent portion of the floating point representation. machar : MachAr The object which calculated these parameters and holds more detailed information. machep : int The exponent that yields ``eps``. max : floating point number of the appropriate type The largest representable number. maxexp : int The smallest positive power of the base (2) that causes overflow. min : floating point number of the appropriate type The smallest representable number, typically ``-max``. minexp : int The most negative power of the base (2) consistent with there being no leading 0's in the mantissa. negep : int The exponent that yields ``epsneg``. nexp : int The number of bits in the exponent including its sign and bias. nmant : int The number of bits in the mantissa. precision : int The approximate number of decimal digits to which this kind of float is precise. resolution : floating point number of the appropriate type The approximate decimal resolution of this type, i.e. ``10**-precision``. tiny : floating point number of the appropriate type The smallest-magnitude usable number. Parameters ---------- dtype : floating point type, dtype, or instance The kind of floating point data type to get information about. See Also -------- MachAr : The implementation of the tests that produce this information. iinfo : The equivalent for integer data types. Notes ----- For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling ``finfo()`` repeatedly inside your functions is not a problem. """ _finfo_cache = {} def __new__(cls, dtype): try: dtype = numeric.dtype(dtype) except TypeError: # In case a float instance was given dtype = numeric.dtype(type(dtype)) obj = cls._finfo_cache.get(dtype,None) if obj is not None: return obj dtypes = [dtype] newdtype = numeric.obj2sctype(dtype) if newdtype is not dtype: dtypes.append(newdtype) dtype = newdtype if not issubclass(dtype, numeric.inexact): raise ValueError, "data type %r not inexact" % (dtype) obj = cls._finfo_cache.get(dtype,None) if obj is not None: return obj if not issubclass(dtype, numeric.floating): newdtype = _convert_to_float[dtype] if newdtype is not dtype: dtypes.append(newdtype) dtype = newdtype obj = cls._finfo_cache.get(dtype,None) if obj is not None: return obj obj = object.__new__(cls)._init(dtype) for dt in dtypes: cls._finfo_cache[dt] = obj return obj def _init(self, dtype): self.dtype = numeric.dtype(dtype) if dtype is ntypes.double: itype = ntypes.int64 fmt = '%24.16e' precname = 'double' elif dtype is ntypes.single: itype = ntypes.int32 fmt = '%15.7e' precname = 'single' elif dtype is ntypes.longdouble: itype = ntypes.longlong fmt = '%s' precname = 'long double' else: raise ValueError, repr(dtype) machar = MachAr(lambda v:array([v], dtype), lambda v:_frz(v.astype(itype))[0], lambda v:array(_frz(v)[0], dtype), lambda v: fmt % array(_frz(v)[0], dtype), 'numpy %s precision floating point number' % precname) for word in ['precision', 'iexp', 'maxexp','minexp','negep', 'machep']: setattr(self,word,getattr(machar, word)) for word in ['tiny','resolution','epsneg']: setattr(self,word,getattr(machar, word).squeeze()) self.max = machar.huge.flat[0] self.min = -self.max self.eps = machar.eps.flat[0] self.nexp = machar.iexp self.nmant = machar.it self.machar = machar self._str_tiny = machar._str_xmin.strip() self._str_max = machar._str_xmax.strip() self._str_epsneg = machar._str_epsneg.strip() self._str_eps = machar._str_eps.strip() self._str_resolution = machar._str_resolution.strip() return self def __str__(self): return '''\ Machine parameters for %(dtype)s --------------------------------------------------------------------- precision=%(precision)3s resolution= %(_str_resolution)s machep=%(machep)6s eps= %(_str_eps)s negep =%(negep)6s epsneg= %(_str_epsneg)s minexp=%(minexp)6s tiny= %(_str_tiny)s maxexp=%(maxexp)6s max= %(_str_max)s nexp =%(nexp)6s min= -max --------------------------------------------------------------------- ''' % self.__dict__ class iinfo: """ iinfo(type) Machine limits for integer types. Attributes ---------- min : int The smallest integer expressible by the type. max : int The largest integer expressible by the type. Parameters ---------- type : integer type, dtype, or instance The kind of integer data type to get information about. See Also -------- finfo : The equivalent for floating point data types. Examples -------- With types: >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647 With instances: >>> ii32 = np.iinfo(np.int32(10)) >>> ii32.min -2147483648 >>> ii32.max 2147483647 """ _min_vals = {} _max_vals = {} def __init__(self, int_type): try: self.dtype = numeric.dtype(int_type) except TypeError: self.dtype = numeric.dtype(type(int_type)) self.kind = self.dtype.kind self.bits = self.dtype.itemsize * 8 self.key = "%s%d" % (self.kind, self.bits) if not self.kind in 'iu': raise ValueError("Invalid integer data type.") def min(self): """Minimum value of given dtype.""" if self.kind == 'u': return 0 else: try: val = iinfo._min_vals[self.key] except KeyError: val = int(-(1L << (self.bits-1))) iinfo._min_vals[self.key] = val return val min = property(min) def max(self): """Maximum value of given dtype.""" try: val = iinfo._max_vals[self.key] except KeyError: if self.kind == 'u': val = int((1L << self.bits) - 1) else: val = int((1L << (self.bits-1)) - 1) iinfo._max_vals[self.key] = val return val max = property(max) def __str__(self): """String representation.""" return '''\ Machine parameters for %(dtype)s --------------------------------------------------------------------- min = %(min)s max = %(max)s --------------------------------------------------------------------- ''' % {'dtype': self.dtype, 'min': self.min, 'max': self.max} if __name__ == '__main__': f = finfo(ntypes.single) print 'single epsilon:',f.eps print 'single tiny:',f.tiny f = finfo(ntypes.float) print 'float epsilon:',f.eps print 'float tiny:',f.tiny f = finfo(ntypes.longfloat) print 'longfloat epsilon:',f.eps print 'longfloat tiny:',f.tiny
Save
cmd:
run