You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arithmetic operations (+, -, *, ...) between a SCICO BlockArray and a NumPy ndarray are defined in the BlockArray docs to work in two cases: (1) when the ndarray is 1d and has size (i.e., number of elements) equal to the number of blocks; (2) when the ndarray has size equal to the size of the BlockArray.
This definition may be over restrictive, e.g.,
x = np.zeros(
(3,)
)
y = BlockArray.zeros(
((1,),)
)
x + y # error
And maybe isn't implemented correctly, e.g.,
x = np.zeros(
(3, 4)
)
y = BlockArray.zeros(
((6,), (6,))
)
assert x.size == y.size
x + y # error
Ideally, we could find a simple principle that would be intuitive and cover all relevant cases. One approach would be to generalize NumPy's scalar + ndarray behavior. That is, consider the ndarray to have been expanded (by duplication) into a BlockArray with the same number of blocks as the BlockArray, then perform the operation on these BlockArrays.
Arithmetic operations (+, -, *, ...) between a SCICO BlockArray and a NumPy ndarray are defined in the BlockArray docs to work in two cases: (1) when the ndarray is 1d and has size (i.e., number of elements) equal to the number of blocks; (2) when the ndarray has size equal to the size of the BlockArray.
This definition may be over restrictive, e.g.,
And maybe isn't implemented correctly, e.g.,
Ideally, we could find a simple principle that would be intuitive and cover all relevant cases. One approach would be to generalize NumPy's scalar + ndarray behavior. That is, consider the ndarray to have been expanded (by duplication) into a BlockArray with the same number of blocks as the BlockArray, then perform the operation on these BlockArrays.
Examples:
The text was updated successfully, but these errors were encountered: