diff options
author | cookedm <cookedm@localhost> | 2006-07-28 20:12:00 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2006-07-28 20:12:00 +0000 |
commit | 02926b0b6c030ec3cbf46eb37227d111c6da0ea8 (patch) | |
tree | 3f14224e6f20e549103658f10a4e493ff9258fef | |
parent | 39bd37d9ee35b8a28aa75ab5e5b0c988c48b0e87 (diff) | |
download | numpy-02926b0b6c030ec3cbf46eb37227d111c6da0ea8.tar.gz |
numpy.lib.getlimits: replace typecodes with dtypes
-rw-r--r-- | numpy/lib/getlimits.py | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py index ce1fc6e6f..297ef9b36 100644 --- a/numpy/lib/getlimits.py +++ b/numpy/lib/getlimits.py @@ -53,29 +53,26 @@ class finfo(object): def _init(self, dtype): self.dtype = dtype - if dtype is numeric.float_: - machar = MachAr(lambda v:array([v],'d'), - lambda v:_frz(v.astype('i'))[0], - lambda v:array(_frz(v)[0],'d'), - lambda v:'%24.16e' % array(_frz(v)[0],'d'), - 'numpy float precision floating point '\ - 'number') - elif dtype is numeric.single: - machar = MachAr(lambda v:array([v],'f'), - lambda v:_frz(v.astype('i'))[0], - lambda v:array(_frz(v)[0],'f'), # - lambda v:'%15.7e' % array(_frz(v)[0],'f'), - "numpy single precision floating "\ - "point number") - elif dtype is numeric.longfloat: - machar = MachAr(lambda v:array([v],'g'), - lambda v:_frz(v.astype('i'))[0], - lambda v:array(_frz(v)[0],'g'), # - lambda v:str(array(_frz(v)[0],'g')), - "numpy longfloat precision floating "\ - "point number") + 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,`dtype` + 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', |