diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2016-01-06 11:37:47 -0500 |
---|---|---|
committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2016-01-06 11:37:47 -0500 |
commit | dbf3fcb19ec710732531c268aeba7aa348e872f1 (patch) | |
tree | f0881529357f1c61957158001fd16883bba9917d /numpy/core/fromnumeric.py | |
parent | 7d67348d3be1bb8193ca771f1004e8cab0361af7 (diff) | |
download | numpy-dbf3fcb19ec710732531c268aeba7aa348e872f1.tar.gz |
BUG trace is not subclass aware, such that np.trace(ma) != ma.trace().
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 362c29cb8..a2937c5c5 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1367,7 +1367,11 @@ def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None): (2, 3) """ - return asarray(a).trace(offset, axis1, axis2, dtype, out) + if isinstance(a, np.matrix): + # Get trace of matrix via an array to preserve backward compatibility. + return asarray(a).trace(offset, axis1, axis2, dtype, out) + else: + return asanyarray(a).trace(offset, axis1, axis2, dtype, out) def ravel(a, order='C'): |