[Numpy-svn] r2714 - trunk/numpy/core

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Jun 30 16:45:57 EDT 2006


Author: cookedm
Date: 2006-06-30 15:45:55 -0500 (Fri, 30 Jun 2006)
New Revision: 2714

Modified:
   trunk/numpy/core/defmatrix.py
Log:
For repr() of a matrix, add an extra space at the beginning of lines to line up columns.


Modified: trunk/numpy/core/defmatrix.py
===================================================================
--- trunk/numpy/core/defmatrix.py	2006-06-30 20:28:48 UTC (rev 2713)
+++ trunk/numpy/core/defmatrix.py	2006-06-30 20:45:55 UTC (rev 2714)
@@ -205,7 +205,14 @@
         return NotImplemented
 
     def __repr__(self):
-        return repr(self.__array__()).replace('array','matrix')
+        s = repr(self.__array__()).replace('array', 'matrix')
+        # now, 'matrix' has 6 letters, and 'array' 5, so the columns don't
+        # line up anymore. We need to add a space.
+        l = s.splitlines()
+        for i in range(1, len(l)):
+            if l[i]:
+                l[i] = ' ' + l[i]
+        return '\n'.join(l)
 
     def __str__(self):
         return str(self.__array__())




More information about the Numpy-svn mailing list