summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMathieu Lamarre <mlamarre@ea.com>2018-02-08 11:00:06 -0500
committerMathieu Lamarre <mlamarre@ea.com>2018-02-08 11:00:21 -0500
commit6c4a77bf87b8a6fcadd7a128f73b8f2954642bec (patch)
tree58a67377975e04713960981aa2e05ba2dfc7ebde /tools
parent12668b65791ef5a5104007e26c53e598b4416235 (diff)
downloadpython-numpy-6c4a77bf87b8a6fcadd7a128f73b8f2954642bec.tar.gz
python-numpy-6c4a77bf87b8a6fcadd7a128f73b8f2954642bec.tar.bz2
python-numpy-6c4a77bf87b8a6fcadd7a128f73b8f2954642bec.zip
Swig tool: Clear CARRAY flag when setting FARRAY
Otherwise the returned array has both flags, which creates all sorts of confusing runtime behaviors. C_CONTIGUOUS : True F_CONTIGUOUS : True Doesn't cause a crash, but some functions like copy() works in F_CONTIGUOUS others like element wise operators assume C_CONTIGUOUS, obviously this becomes a nightmare to debug.
Diffstat (limited to 'tools')
-rw-r--r--tools/swig/numpy.i2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/swig/numpy.i b/tools/swig/numpy.i
index 5f2aa0a5d..686e11eaf 100644
--- a/tools/swig/numpy.i
+++ b/tools/swig/numpy.i
@@ -94,6 +94,7 @@
%#define array_descr(a) PyArray_DESCR((PyArrayObject*)a)
%#define array_flags(a) PyArray_FLAGS((PyArrayObject*)a)
%#define array_enableflags(a,f) PyArray_ENABLEFLAGS((PyArrayObject*)a,f)
+%#define array_clearflags(a,f) PyArray_CLEARFLAGS((PyArrayObject*)a,f)
%#define array_is_fortran(a) (PyArray_IS_F_CONTIGUOUS((PyArrayObject*)a))
%#endif
%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS((PyArrayObject*)a))
@@ -539,6 +540,7 @@
npy_intp * strides = array_strides(ary);
if (array_is_fortran(ary)) return success;
/* Set the Fortran ordered flag */
+ array_clearflags(ary,NPY_ARRAY_CARRAY);
array_enableflags(ary,NPY_ARRAY_FARRAY);
/* Recompute the strides */
strides[0] = strides[nd-1];