summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-02-24 10:36:36 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-02-24 10:36:36 +0000
commit8db604ba730d0d64b6491cee731ef363d459207f (patch)
treede7f944285123ab9e064a1f560f67f3fc9bdb719 /numpy/core/src/arrayobject.c
parent14f6333ced59fcd3d04f302e166eaf2355f1da7f (diff)
downloadnumpy-8db604ba730d0d64b6491cee731ef363d459207f.tar.gz
Fix problem with subspace indexing an matrix subclass
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index afca2b618..532daf31b 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -7466,8 +7466,19 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
therefore we can extract the subspace with a simple
getitem call which will use view semantics
*/
-
- sub = PyObject_GetItem((PyObject *)arr, mit->indexobj);
+ /* But, be sure to do it with a true array.
+ */
+ if (PyArray_CheckExact(arr)) {
+ sub = array_subscript(arr, mit->indexobj);
+ }
+ else {
+ Py_INCREF(arr);
+ obj = PyArray_EnsureArray((PyObject *)arr);
+ if (obj == NULL) goto fail;
+ sub = array_subscript((PyArrayObject *)obj, mit->indexobj);
+ Py_DECREF(obj);
+ }
+
if (sub == NULL) goto fail;
mit->subspace = (PyArrayIterObject *)PyArray_IterNew(sub);
Py_DECREF(sub);