Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a
filterhelper function topytensor/scan/views.py, complementing the existingmap,reduce,foldl, andfoldrutilities.The new
filterfunction applies a user-defined condition (predicate) over a sequence using PyTensor’sscanoperation and returns only the elements that satisfy the condition (i.e., the ones for which the predicate evaluates toTrue).This addition restores functionality discussed in Theano/Theano#5365, now updated for PyTensor where boolean indexing is supported natively.
A corresponding unit test (
test_filter) was added intests/scan/test_views.pyto ensure correct behavior.Related Issue
scan/views.py#1711Checklist
test_filter) that verifies the correctness of the new functionfilter)Type of change
@ricardoV94, please take a look when available