[Numpy-svn] r6322 - trunk/numpy/lib

numpy-svn@scip... numpy-svn@scip...
Wed Jan 14 01:55:31 CST 2009


Author: stefan
Date: 2009-01-14 01:55:16 -0600 (Wed, 14 Jan 2009)
New Revision: 6322

Modified:
   trunk/numpy/lib/getlimits.py
Log:
Fix printing of limits.

Modified: trunk/numpy/lib/getlimits.py
===================================================================
--- trunk/numpy/lib/getlimits.py	2009-01-14 07:14:27 UTC (rev 6321)
+++ trunk/numpy/lib/getlimits.py	2009-01-14 07:55:16 UTC (rev 6322)
@@ -115,7 +115,7 @@
         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 @@
         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 @@
 
     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



More information about the Numpy-svn mailing list