@@ -95,7 +95,6 @@ NpyIter_GlobalFlagsConverter(PyObject *flags_in, npy_uint32 *flags)
95
95
npy_uint32 flag ;
96
96
97
97
if (flags_in == NULL || flags_in == Py_None ) {
98
- * flags = 0 ;
99
98
return 1 ;
100
99
}
101
100
@@ -526,7 +525,7 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp nop,
526
525
return 0 ;
527
526
}
528
527
529
- * oa_ndim = 0 ;
528
+ * oa_ndim = -1 ;
530
529
531
530
/* Copy the tuples into op_axes */
532
531
for (iop = 0 ; iop < nop ; ++ iop ) {
@@ -545,13 +544,8 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp nop,
545
544
Py_DECREF (a );
546
545
return 0 ;
547
546
}
548
- if (* oa_ndim == 0 ) {
547
+ if (* oa_ndim == -1 ) {
549
548
* oa_ndim = PySequence_Size (a );
550
- if (* oa_ndim == 0 ) {
551
- PyErr_SetString (PyExc_ValueError ,
552
- "op_axes must have at least one dimension" );
553
- return 0 ;
554
- }
555
549
if (* oa_ndim > NPY_MAXDIMS ) {
556
550
PyErr_SetString (PyExc_ValueError ,
557
551
"Too many dimensions in op_axes" );
@@ -575,7 +569,7 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp nop,
575
569
op_axes [iop ][idim ] = -1 ;
576
570
}
577
571
else {
578
- op_axes [iop ][idim ] = PyInt_AsLong (v );
572
+ op_axes [iop ][idim ] = PyArray_PyIntAsInt (v );
579
573
if (op_axes [iop ][idim ]== -1 &&
580
574
PyErr_Occurred ()) {
581
575
Py_DECREF (a );
@@ -589,7 +583,7 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp nop,
589
583
}
590
584
}
591
585
592
- if (* oa_ndim == 0 ) {
586
+ if (* oa_ndim == -1 ) {
593
587
PyErr_SetString (PyExc_ValueError ,
594
588
"If op_axes is provided, at least one list of axes "
595
589
"must be contained within it" );
@@ -726,7 +720,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
726
720
NPY_CASTING casting = NPY_SAFE_CASTING ;
727
721
npy_uint32 op_flags [NPY_MAXARGS ];
728
722
PyArray_Descr * op_request_dtypes [NPY_MAXARGS ];
729
- int oa_ndim = 0 ;
723
+ int oa_ndim = -1 ;
730
724
int op_axes_arrays [NPY_MAXARGS ][NPY_MAXDIMS ];
731
725
int * op_axes [NPY_MAXARGS ];
732
726
PyArray_Dims itershape = {NULL , 0 };
@@ -784,7 +778,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
784
778
}
785
779
786
780
if (itershape .len > 0 ) {
787
- if (oa_ndim == 0 ) {
781
+ if (oa_ndim == -1 ) {
788
782
oa_ndim = itershape .len ;
789
783
memset (op_axes , 0 , sizeof (op_axes [0 ]) * nop );
790
784
}
@@ -800,10 +794,9 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
800
794
itershape .ptr = NULL ;
801
795
}
802
796
803
-
804
797
self -> iter = NpyIter_AdvancedNew (nop , op , flags , order , casting , op_flags ,
805
798
op_request_dtypes ,
806
- oa_ndim , oa_ndim > 0 ? op_axes : NULL ,
799
+ oa_ndim , oa_ndim >= 0 ? op_axes : NULL ,
807
800
itershape .ptr ,
808
801
buffersize );
809
802
@@ -860,7 +853,7 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
860
853
861
854
int iop , nop = 0 , inest , nnest = 0 ;
862
855
PyArrayObject * op [NPY_MAXARGS ];
863
- npy_uint32 flags = 0 , flags_inner = 0 ;
856
+ npy_uint32 flags = 0 , flags_inner ;
864
857
NPY_ORDER order = NPY_KEEPORDER ;
865
858
NPY_CASTING casting = NPY_SAFE_CASTING ;
866
859
npy_uint32 op_flags [NPY_MAXARGS ], op_flags_inner [NPY_MAXARGS ];
0 commit comments