Skip to content

Make behaviour of compute consistent for slicing #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 30, 2025
Merged

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