summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py19
-rw-r--r--numpy/f2py/tests/array_from_pyobj/wrapmodule.c8
2 files changed, 16 insertions, 11 deletions
diff --git a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
index 281018b64..dd9a64999 100644
--- a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
+++ b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
@@ -3,7 +3,9 @@ import sys
import copy
from numpy.testing import *
-from numpy import array, typeinfo, alltrue, ndarray, asarray, can_cast,zeros
+from numpy import array, alltrue, ndarray, asarray, can_cast,zeros, dtype
+from numpy.core.multiarray import typeinfo
+
set_package_path()
from array_from_pyobj import wrap
del sys.path[0]
@@ -85,11 +87,11 @@ class Type(object):
def __new__(cls,name):
- if isinstance(name,type):
- dtype = name
+ if isinstance(name,dtype):
+ dtype0 = name
name = None
for n,i in typeinfo.items():
- if isinstance(i,tuple) and dtype is i[-1]:
+ if isinstance(i,tuple) and dtype0.type is i[-1]:
name = n
break
obj = cls._type_cache.get(name.upper(),None)
@@ -219,7 +221,8 @@ class Array:
def arr_equal(self,arr1,arr2):
if arr1.shape != arr2.shape:
return False
- return alltrue(arr1==arr2)
+ s = arr1==arr2
+ return alltrue(s.flatten())
def __str__(self):
return str(self.arr)
@@ -486,8 +489,8 @@ class _test_shared_memory:
if t is self.type:
continue
obj = array(self.num23seq,dtype=t.dtype)
- assert obj.dtype==t.dtype
- assert obj.dtype is not self.type.dtype
+ assert obj.dtype.type==t.dtype
+ assert obj.dtype.type is not self.type.dtype
assert not obj.flags['FORTRAN'] and obj.flags['CONTIGUOUS']
shape = obj.shape
a = self.array(shape,intent.inplace,obj)
@@ -497,7 +500,7 @@ class _test_shared_memory:
assert a.arr is obj
assert obj.flags['FORTRAN'] # obj attributes are changed inplace!
assert not obj.flags['CONTIGUOUS']
- assert obj.dtype is self.type.dtype # obj type is changed inplace!
+ assert obj.dtype.type is self.type.dtype # obj type is changed inplace!
for t in Type._type_names:
exec '''\
diff --git a/numpy/f2py/tests/array_from_pyobj/wrapmodule.c b/numpy/f2py/tests/array_from_pyobj/wrapmodule.c
index ea106d9ac..07d0135cc 100644
--- a/numpy/f2py/tests/array_from_pyobj/wrapmodule.c
+++ b/numpy/f2py/tests/array_from_pyobj/wrapmodule.c
@@ -104,7 +104,7 @@ static PyObject *f2py_rout_wrap_attrs(PyObject *capi_self,
arr->descr->elsize,
arr->descr->alignment,
arr->flags,
- arr->itemsize);
+ PyArray_ITEMSIZE(arr));
}
static PyMethodDef f2py_module_methods[] = {
@@ -167,17 +167,19 @@ DL_EXPORT(void) initwrap(void) {
PyDict_SetItemString(d, "CONTIGUOUS", PyInt_FromLong(CONTIGUOUS));
PyDict_SetItemString(d, "FORTRAN", PyInt_FromLong(FORTRAN));
PyDict_SetItemString(d, "OWNDATA", PyInt_FromLong(OWNDATA));
+ PyDict_SetItemString(d, "FORCECAST", PyInt_FromLong(FORCECAST));
PyDict_SetItemString(d, "ENSURECOPY", PyInt_FromLong(ENSURECOPY));
PyDict_SetItemString(d, "ENSUREARRAY", PyInt_FromLong(ENSUREARRAY));
PyDict_SetItemString(d, "ALIGNED", PyInt_FromLong(ALIGNED));
- PyDict_SetItemString(d, "NOTSWAPPED", PyInt_FromLong(NOTSWAPPED));
PyDict_SetItemString(d, "WRITEABLE", PyInt_FromLong(WRITEABLE));
PyDict_SetItemString(d, "UPDATEIFCOPY", PyInt_FromLong(UPDATEIFCOPY));
PyDict_SetItemString(d, "BEHAVED_FLAGS", PyInt_FromLong(BEHAVED_FLAGS));
- PyDict_SetItemString(d, "BEHAVED_FLAGS_RO", PyInt_FromLong(BEHAVED_FLAGS_RO));
+ PyDict_SetItemString(d, "BEHAVED_NS_FLAGS", PyInt_FromLong(BEHAVED_NS_FLAGS));
PyDict_SetItemString(d, "CARRAY_FLAGS", PyInt_FromLong(CARRAY_FLAGS));
PyDict_SetItemString(d, "FARRAY_FLAGS", PyInt_FromLong(FARRAY_FLAGS));
+ PyDict_SetItemString(d, "CARRAY_FLAGS_RO", PyInt_FromLong(CARRAY_FLAGS_RO));
+ PyDict_SetItemString(d, "FARRAY_FLAGS_RO", PyInt_FromLong(FARRAY_FLAGS_RO));
PyDict_SetItemString(d, "DEFAULT_FLAGS", PyInt_FromLong(DEFAULT_FLAGS));
PyDict_SetItemString(d, "UPDATE_ALL_FLAGS", PyInt_FromLong(UPDATE_ALL_FLAGS));