Skip to content

Make behaviour of compute consistent for slicing#419

Merged
lshaw8317 merged 7 commits intomainfrom
fixConditions
May 30, 2025
Merged

Make behaviour of compute consistent for slicing#419
lshaw8317 merged 7 commits intomainfrom
fixConditions

Conversation

@lshaw8317
Copy link
Collaborator

@lshaw8317 lshaw8317 commented May 30, 2025

As discussed in #399, there were problems for slicing lazy expressions with one where condition, since the output is in general of a different length to the input.
The .compute function when provided with a slice argument internally takes slices of the operands prior to evaluating the expression. One could change this, but I think it is better to interpret the argument as slicing operands prior to calculation. If one is interested in a general slice of the full result one can always force via expr.compute().slice(sl).
An unfortunate consequence is that the syntax of the get_item method is a little misleading (hence why I have changed the tests).

expr.compute(sl)[:] is equal to the numpy syntax nsa1[sl][ne_evaluate(expr)[sl]].

@lshaw8317 lshaw8317 merged commit 7eabaf0 into main May 30, 2025
13 checks passed
@lshaw8317 lshaw8317 deleted the fixConditions branch May 30, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants