This function initializes a result array for a reduction operation which has no identity. This means it needs to copy the first element it sees along the reduction axes to result, then return a view of the operand which excludes that element.
If a reduction has an identity, such as 0 or 1, the result should be initialized by calling PyArray_AssignZero(result, NULL, NULL) or PyArray_AssignOne(result, NULL, NULL), because this function raises an exception when there are no elements to reduce (which appropriate iff the reduction operation has no identity).
This means it copies the subarray indexed at zero along each reduction axis into 'result', then returns a view into 'operand' excluding those copied elements.
- result : The array into which the result is computed. This must have
- the same number of dimensions as 'operand', but for each axis i where 'axis_flags[i]' is True, it has a single element.
System Message: WARNING/2 (<string>
, line 19) Definition list ends without a blank line; unexpected unindent.
operand : The array being reduced. axis_flags : An array of boolean flags, one for each axis of 'operand'.
System Message: ERROR/3 (<string>
, line 21) Unexpected indentation.
<blockquote> When a flag is True, it indicates to reduce along that axis.</blockquote>
System Message: WARNING/2 (<string>
, line 22) Block quote ends without a blank line; unexpected unindent.
- reorderable : If True, the reduction being done is reorderable, which
- means specifying multiple axes of reduction at once is ok, and the reduction code may calculate the reduction in an arbitrary order. The calculation may be reordered because of cache behavior or multithreading requirements.
- out_skip_first_count : This gets populated with the number of first-visit
- elements that should be skipped during the iteration loop.
- funcname : The name of the reduction operation, for the purpose of
- better quality error messages. For example, "numpy.max" would be a good name for NumPy's max function.
Returns a view which contains the remaining elements on which to do the reduction.
Default to no skipping first-visit elements in the iteration
If this reduction is non-reorderable, make sure there are only 0 or 1 axes in axis_flags.
Take a view into 'operand' which we can modify.
Now copy the subarray of the first element along each reduction axis, then return a view to the rest.
Adjust the shape to only look at the first element along any of the reduction axes. We count the number of reduction axes at the same time.
Copy the elements into the result to start.
If there is one reduction axis, adjust the view's shape to only look at the remaining elements
If there are zero reduction axes, make the view empty
Otherwise iterate over the whole operand, but tell the inner loop to skip the elements we already copied by setting the skip_first_count.