8000 Fixed issue #9 "Mismatch of shapes not detected in bridge" · cphvb/numpy@6a1fdde · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a1fdde

Browse files
committed
Fixed issue numpy#9 "Mismatch of shapes not detected in bridge"
1 parent acd5ae9 commit 6a1fdde

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

numpy/core/src/multiarray/ctors.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,28 @@ PyArray_CopyInto(PyArrayObject *dst, PyArrayObject *src)
26892689
if((dst_base != NULL && PyCphVB_ARRAY(dst_base) != NULL) ||
26902690
(src_base != NULL && PyCphVB_ARRAY(src_base) != NULL))
26912691
{
2692+
//In order to make sure that the two array shapes match
2693+
//we create a new iterator.
2694+
PyArrayObject *op[2];
2695+
npy_uint32 op_flags[2];
2696+
NpyIter *iter;
2697+
op[0] = dst;
2698+
op[1] = src;
2699+
op_flags[0] = NPY_ITER_WRITEONLY;
2700+
op_flags[1] = NPY_ITER_READONLY;
2701+
iter = NpyIter_MultiNew(2, op,
2702+
NPY_ITER_EXTERNAL_LOOP|
2703+
NPY_ITER_REFS_OK|
2704+
NPY_ITER_ZEROSIZE_OK,
2705+
NPY_KEEPORDER,
2706+
NPY_NO_CASTING,
2707+
op_flags,
2708+
NULL);
2709+
if(iter == NULL)
2710+
return -1;
2711+
else
2712+
NpyIter_Deallocate(iter);
2713+
26922714
int cphret = PyCphVB_CopyInto(dst, src);
26932715
if(cphret != 1)//PyCphVB_CopyInto() was performed.
26942716
return cphret;

0 commit comments

Comments
 (0)
0