summaryrefslogtreecommitdiff
path: root/scipy/base/matrix.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-10-01 23:50:35 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-10-01 23:50:35 +0000
commit7124b14d4868dd50fa9e04aa7f7f10297dd006e3 (patch)
treea948284c34e01a7be23e686bf69c8c94b17770e0 /scipy/base/matrix.py
parent3778b72342ba0264b20309364285e5ce54687b4a (diff)
downloadnumpy-7124b14d4868dd50fa9e04aa7f7f10297dd006e3.tar.gz
Matrix indexing weirdness
Diffstat (limited to 'scipy/base/matrix.py')
-rw-r--r--scipy/base/matrix.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/scipy/base/matrix.py b/scipy/base/matrix.py
index 2d590c2e6..dfe3cc0a3 100644
--- a/scipy/base/matrix.py
+++ b/scipy/base/matrix.py
@@ -1,6 +1,6 @@
import numeric as N
-from numeric import ArrayType, concatenate
+from numeric import ArrayType, concatenate, integer
from function_base import binary_repr
import types
import string as str_
@@ -103,18 +103,20 @@ class matrix(N.ndarray):
return
def __getitem__(self, index):
- out = N.ndarray.__getitem__(self, index)
+ out = (self.A)[index]
# Need to swap if slice is on first index
try:
n = len(index)
- if (n > 1) and isinstance(index[0], types.SliceType) \
- and (isinstance(index[1], types.IntType) or
- isinstance(index[1], types.LongType)):
- sh = out.shape
- out.shape = (sh[1], sh[0])
+ if (n > 1) and isinstance(index[0], types.SliceType):
+ if (isinstance(index[1], types.IntType) or
+ isinstance(index[1], types.LongType) or
+ isinstance(index[1], integer)):
+ sh = out.shape
+ out.shape = (sh[1], sh[0])
+ return matrix(out)
+ return out
except TypeError:
- pass
- return out
+ return matrix(out)
def __mul__(self, other):
if isinstance(other, N.ndarray) and other.ndim == 0: