Closed gRox167 closed 5 months ago
I have searched the Issue Tracker that this hasn't already been reported. (comment there if it has.)
When we want to select specific slice of data, and get the remaining data we can do
x = np.zeros(5,4) front_idx = 1 select_idx = front+2 selected = x[front_idx:select_idx] remained = np.concatenate(x[0:front_idx], x[select_idx: ])
In the bestcase, we can use ein expression (front + select + end) d -> (front + end) d, b d to describe this operation
(front + select + end) d -> (front + end) d, b d
x = np.zeros(5,4) remained, selected = einx.rearrange( "(front + select + end) d -> (front + end) d, select d", x, front=1, select=2)
which is fine, however if we exchange the sequence of output and ein expression:
x = np.zeros((5, 4)) selected, remained = einx.rearrange( "(front + select + end) d -> select d, (front + end) d", x, front=1, select=2 )
einx raised an error:
[165] einx/op/util.py:165 subtensor = _unflatten(exprs_in, tensors_in, subexpr, backend) AssertionError:
Yes, this should indeed work, but didn't due to a bug. Thanks for bringing it up, it should be fixed with https://github.com/fferflo/einx/commit/a313bc530f94738168b5b6a9e6bb1d3205fd0ea0.
Required prerequisites
I have searched the Issue Tracker that this hasn't already been reported. (comment there if it has.)
Problem
When we want to select specific slice of data, and get the remaining data we can do
In the bestcase, we can use ein expression
(front + select + end) d -> (front + end) d, b d
to describe this operationwhich is fine, however if we exchange the sequence of output and ein expression:
einx raised an error: