diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2015-01-03 17:11:32 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2015-01-04 08:17:46 -0700 |
commit | ad2d26442a4cf39ca378040f56ee928e673ad42a (patch) | |
tree | a34132b2c193f4b4ba8d45c20056924811eb55c9 /numpy/lib/twodim_base.py | |
parent | 7fbc43b98d59ef982671b456cebc229425ae7e4e (diff) | |
download | numpy-ad2d26442a4cf39ca378040f56ee928e673ad42a.tar.gz |
BUG: Make diag, diagonal return 1-D arrays for matrix arguments.
This is an ugly hack to preserve backwards compatibility for code
that uses matrices. It is needed since both diag and diagonal have
been changed to preserve subtypes otherwise.
Note that a.diagonal() still returns matrices when a is a matrix.
Diffstat (limited to 'numpy/lib/twodim_base.py')
-rw-r--r-- | numpy/lib/twodim_base.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 25504e434..24dc3cced 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -5,7 +5,7 @@ from __future__ import division, absolute_import, print_function from numpy.core.numeric import ( asanyarray, arange, zeros, greater_equal, multiply, ones, asarray, - where, int8, int16, int32, int64, empty, promote_types + where, int8, int16, int32, int64, empty, promote_types, diagonal, ) from numpy.core import iinfo @@ -307,7 +307,7 @@ def diag(v, k=0): res[:n-k].flat[i::n+1] = v return res elif len(s) == 2: - return v.diagonal(k) + return diagonal(v, k) else: raise ValueError("Input must be 1- or 2-d.") |