An array assignment function for copying arrays, broadcasting 'src' into 'dst'. This function makes a temporary copy of 'src' if 'src' and 'dst' overlap, to be able to handle views of the same data with different strides.
dst: The destination array. src: The source array. wheremask: If non-NULL, a boolean mask specifying where to copy. casting: An exception is raised if the copy violates this
System Message: ERROR/3 (<string>
, line 10) Unexpected indentation.
<blockquote> casting rule.</blockquote>
Returns 0 on success, -1 on failure.
Use array_assign_scalar if 'src' NDIM is 0
Performance fix for expressions like "a[1000:6000] += x". In this case, first an in-place add is done, followed by an assignment, equivalently expressed like this: <blockquote> tmp = a[1000:6000] # Calls array_subscript in mapping.c np.add(tmp, x, tmp) a[1000:6000] = tmp # Calls array_assign_subscript in mapping.c</blockquote>
In the assignment the underlying data type, shape, strides, and data pointers are identical, but src != dst because they are separately generated slices. By detecting this and skipping the redundant copy of values to themselves, we potentially give a big speed boost.
Note that we don't call EquivTypes, because usually the exact same dtype object will appear, and we don't want to slow things down with a complicated comparison. The comparisons are ordered to try and reject this with as little work as possible.
printf("Redundant copy operation detectedn");
Check the casting rule
When ndim is 1 and the strides point in the same direction, the lower-level inner loop handles copying of overlapping data. For bigger ndim and opposite-strided 1D data, we make a temporary copy of 'src' if 'src' and 'dst' overlap.'
Allocate a temporary copy array.
Broadcast 'src' to 'dst' for raw iteration
As a special case for backwards compatibility, strip away unit dimensions from the left of 'src'
A straightforward value assignment
Do the assignment with raw array iteration
Broadcast the wheremask to 'dst' for raw iteration
A straightforward where-masked assignment
Do the masked assignment with raw array iteration
Referenced by _array_fromobject().