sequential_array_add¶
- sofia_redux.scan.utilities.numba_functions.sequential_array_add(array, add_values, at_indices, valid_array=None, valid_indices=None)[source]¶
Add one array of values to another.
Unlike standard adding, values can be added from
add_values
to a single index ofarray
multiple times.- Parameters:
- arraynumpy.ndarray (float or int)
The array to add to of shape (shape1). Addition will be performed in-place.
- add_valuesnumpy.ndarray (float or int)
The values to add to the array of shape (shape2)
- at_indicesnumpy.ndarray (int)
The indices on
array
for which to addadd_values
. Must be of shape (n_dimensions, values.size or add_values.shape). One-dimensional arrays may be of shape (values.size,).- valid_arraynumpy.ndarray (bool), optional
An array of shape (shape1) where
True
indicates thatarray
may be added to at that index.- valid_indicesnumpy.ndarray (bool), optional
An array of shape (shape2) where
False
excludes the same element ofadd_values
from being added toarray
.
- Returns:
Examples
>>> x = np.zeros(5) >>> y = np.ones(5) >>> indices = np.array([0, 0, 3, 3, 3]) >>> added = sequential_array_add(x, y, indices) >>> print(added, x) [ True False False True False] [2. 0. 0. 3. 0.]