Skip to content

Update tensor.where to allow for case with only condition #844

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 8 commits into from
Jun 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pytensor/tensor/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,12 @@
"""if cond then ift else iff"""


where = switch
# where = switch
def where(cond, ift, iff):
if ift is not None and iff is not None:
return switch(cond, ift, iff)
else:
return cond.nonzero()

Check warning on line 768 in pytensor/tensor/basic.py

View check run for this annotation

Codecov / codecov/patch

pytensor/tensor/basic.py#L768

Added line #L768 was not covered by tests


@scalar_elemwise
Expand Down
Loading