diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2009-01-14 07:55:16 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2009-01-14 07:55:16 +0000 |
commit | 1775a591a73fe76162ea871f07349648620ac5b5 (patch) | |
tree | e65b52d6f3c0354c27c72f4770e36be0f8ab7fa7 /numpy/lib/getlimits.py | |
parent | 2d1f2e075b51effc392019f0dce6d5e777adf4e4 (diff) | |
download | numpy-1775a591a73fe76162ea871f07349648620ac5b5.tar.gz |
Fix printing of limits.
Diffstat (limited to 'numpy/lib/getlimits.py')
-rw-r--r-- | numpy/lib/getlimits.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py index bc5fbbf5e..658549179 100644 --- a/numpy/lib/getlimits.py +++ b/numpy/lib/getlimits.py @@ -115,7 +115,7 @@ class finfo(object): return obj def _init(self, dtype): - self.dtype = dtype + self.dtype = np.dtype(dtype) if dtype is ntypes.double: itype = ntypes.int64 fmt = '%24.16e' @@ -149,23 +149,23 @@ class finfo(object): self.nexp = machar.iexp self.nmant = machar.it self.machar = machar - self._str_tiny = machar._str_xmin - self._str_max = machar._str_xmax - self._str_epsneg = machar._str_epsneg - self._str_eps = machar._str_eps - self._str_resolution = machar._str_resolution + 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 +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__ @@ -256,6 +256,17 @@ class iinfo: 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 |