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 of array 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 add add_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 that array may be added to at that index.

valid_indicesnumpy.ndarray (bool), optional

An array of shape (shape2) where False excludes the same element of add_values from being added to array.

Returns:
addednumpy.ndarray (bool)

An array the same shape as array where True indicates that an element has been added to.

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.]