From 7ab5d9e22c75cea09a808d0bfe7419c97a928732 Mon Sep 17 00:00:00 2001 From: cookedm Date: Fri, 30 Jun 2006 20:45:55 +0000 Subject: For repr() of a matrix, add an extra space at the beginning of lines to line up columns. --- numpy/core/defmatrix.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'numpy/core/defmatrix.py') 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__()) -- cgit v1.2.1