@@ -54,8 +54,7 @@ static int
54
54
npyiter_fill_axisdata (NpyIter * iter , npy_uint32 flags , npyiter_opitflags * op_itflags ,
55
55
char * * op_dataptr ,
56
56
npy_uint32 * op_flags , int * * op_axes ,
57
- npy_intp * itershape ,
58
- int output_scalars );
57
+ npy_intp * itershape );
59
58
static void
60
59
npyiter_replace_axisdata (NpyIter * iter , int iop ,
61
60
PyArrayObject * op ,
@@ -74,8 +73,7 @@ npyiter_find_best_axis_ordering(NpyIter *iter);
74
73
static PyArray_Descr *
75
74
npyiter_get_common_dtype (int nop , PyArrayObject * * op ,
76
75
npyiter_opitflags * op_itflags , PyArray_Descr * * op_dtype ,
77
- PyArray_Descr * * op_request_dtypes ,
78
- int only_inputs , int output_scalars );
76
+ PyArray_Descr * * op_request_dtypes , int only_inputs );
79
77
static PyArrayObject *
80
78
npyiter_new_temp_array (NpyIter * iter , PyTypeObject * subtype ,
81
79
npy_uint32 flags , npyiter_opitflags * op_itflags ,
@@ -86,7 +84,7 @@ npyiter_allocate_arrays(NpyIter *iter,
86
84
npy_uint32 flags ,
87
85
PyArray_Descr * * op_dtype , PyTypeObject * subtype ,
88
86
npy_uint32 * op_flags , npyiter_opitflags * op_itflags ,
89
- int * * op_axes , int output_scalars );
87
+ int * * op_axes );
90
88
static void
91
89
npyiter_get_priority_subtype (int nop , PyArrayObject * * op ,
92
90
npyiter_opitflags * op_itflags ,
@@ -123,7 +121,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
123
121
npy_int8 * perm ;
124
122
NpyIter_BufferData * bufferdata = NULL ;
125
123
int any_allocate = 0 , any_missing_dtypes = 0 ,
126
- output_scalars = 0 , need_subtype = 0 ;
124
+ need_subtype = 0 ;
127
125
128
126
/* The subtype for automatically allocated outputs */
129
127
double subtype_priority = NPY_PRIORITY ;
@@ -177,7 +175,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
177
175
178
176
/* If 'ndim' is zero, any outputs should be scalars */
179
177
if (ndim == 0 ) {
180
- output_scalars = 1 ;
178
+ itflags |= NPY_ITFLAG_SCALAR ;
181
179
ndim = 1 ;
182
180
}
183
181
@@ -231,8 +229,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
231
229
232
230
/* Fill in the AXISDATA arrays and set the ITERSIZE field */
233
231
if (!npyiter_fill_axisdata (iter , flags , op_itflags , op_dataptr ,
234
- op_flags , op_axes , itershape ,
235
- output_scalars )) {
232
+ op_flags , op_axes , itershape )) {
236
233
NpyIter_Deallocate (iter );
237
234
return NULL ;
238
235
}
@@ -338,8 +335,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
338
335
dtype = npyiter_get_common_dtype (nop , op ,
339
336
op_itflags , op_dtype ,
340
337
op_request_dtypes ,
341
- only_inputs ,
342
- output_scalars );
338
+ only_inputs );
343
339
if (dtype == NULL ) {
344
340
NpyIter_Deallocate (iter );
345
341
return NULL ;
@@ -389,7 +385,7 @@ NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags,
389
385
* done now using a memory layout matching the iterator.
390
386
*/
391
387
if (!npyiter_allocate_arrays (iter , flags , op_dtype , subtype , op_flags ,
392
- op_itflags , op_axes , output_scalars )) {
388
+ op_itflags , op_axes )) {
393
389
NpyIter_Deallocate (iter );
394
390
return NULL ;
395
391
}
@@ -1437,8 +1433,7 @@ static int
1437
1433
npyiter_fill_axisdata (NpyIter * iter , npy_uint32 flags , npyiter_opitflags * op_itflags ,
1438
1434
char * * op_dataptr ,
1439
1435
npy_uint32 * op_flags , int * * op_axes ,
1440
- npy_intp * itershape ,
1441
- int output_scalars )
1436
+ npy_intp * itershape )
1442
1437
{
1443
1438
npy_uint32 itflags = NIT_ITFLAGS (iter );
1444
1439
int idim , ndim = NIT_NDIM (iter );
@@ -1558,7 +1553,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, npyiter_opitflags *op_itf
1558
1553
ondim = PyArray_NDIM (op_cur );
1559
1554
if (bshape == 1 ) {
1560
1555
strides [iop ] = 0 ;
1561
- if (idim >= ondim && !output_scalars &&
1556
+ if (idim >= ondim && !( itflags & NPY_ITFLAG_SCALAR ) &&
1562
1557
(op_flags [iop ] & NPY_ITER_NO_BROADCAST )) {
1563
1558
goto operand_different_than_broadcast ;
1564
1559
}
@@ -2393,8 +2388,7 @@ npyiter_find_best_axis_ordering(NpyIter *iter)
2393
2388
static PyArray_Descr *
2394
2389
npyiter_get_common_dtype (int nop , PyArrayObject * * op ,
2395
2390
npyiter_opitflags * op_itflags , PyArray_Descr * * op_dtype ,
2396
- PyArray_Descr * * op_request_dtypes ,
2397
- int only_inputs , int output_scalars )
2391
+ PyArray_Descr * * op_request_dtypes , int only_inputs )
2398
2392
{
2399
2393
int iop ;
2400
2394
npy_intp narrs = 0 , ndtypes = 0 ;
@@ -2693,7 +2687,7 @@ npyiter_allocate_arrays(NpyIter *iter,
2693
2687
npy_uint32 flags ,
2694
2688
PyArray_Descr * * op_dtype , PyTypeObject * subtype ,
2695
2689
npy_uint32 * op_flags , npyiter_opitflags * op_itflags ,
2696
- int * * op_axes , int output_scalars )
2690
+ int * * op_axes )
2697
2691
{
2698
2692
npy_uint32 itflags = NIT_ITFLAGS (iter );
2699
2693
int idim , ndim = NIT_NDIM (iter );
@@ -2724,7 +2718,7 @@ npyiter_allocate_arrays(NpyIter *iter,
2724
2718
if (op [iop ] == NULL ) {
2725
2719
PyArrayObject * out ;
2726
2720
PyTypeObject * op_subtype ;
2727
- int ondim = output_scalars ? 0 : ndim ;
2721
+ int ondim = ( itflags & NPY_ITFLAG_SCALAR ) ? 0 : ndim ;
2728
2722
2729
2723
/* Check whether the subtype was disabled */
2730
2724
op_subtype = (op_flags [iop ] & NPY_ITER_NO_SUBTYPE ) ?
0 commit comments