summaryrefslogtreecommitdiff
path: root/numpy/core/defmatrix.py
diff options
context:
space:
mode:
authorcookedm <cookedm@localhost>2006-06-30 20:45:55 +0000
committercookedm <cookedm@localhost>2006-06-30 20:45:55 +0000
commit7ab5d9e22c75cea09a808d0bfe7419c97a928732 (patch)
tree821f5569ced9a4a1fa60396d4d2784fa76d92a00 /numpy/core/defmatrix.py
parent8ba48b04185cac855257173b664883e18b5f3172 (diff)
downloadnumpy-7ab5d9e22c75cea09a808d0bfe7419c97a928732.tar.gz
For repr() of a matrix, add an extra space at the beginning of lines to line up columns.
Diffstat (limited to 'numpy/core/defmatrix.py')
-rw-r--r--numpy/core/defmatrix.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index d76eafea3..839c4f058 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -205,7 +205,14 @@ class matrix(N.ndarray):
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__())