pytensor
pytensor copied to clipboard
Change behavior of helper set/inc to act on an indexed variable directly
Description
Reverting back to the option first suggested in https://github.com/pymc-devs/pytensor/pull/493 and then overridden in https://github.com/pymc-devs/pytensor/pull/494
The [ ]
is the only way that allows for the Python slice :
syntax, and cannot be reproduced otherwise. The current helper methods of set
/inc
require indexes to be passed as a tuple, and so users would need to write x.set((..., slice(None), 0), y)
if they wanted a shortcut to pt.set_subtensor(x[..., :, 0], y)
, at which point the helper ceases to help at all. The reverted API instead looks like x[..., :, 0].set(y)
I still think a helper is useful because it's more discoverable and considerably more succinct than the function alternatives. If people disagree I would instead remove the method helpers altogether.
Related Issue
- [ ] Closes #
- [ ] Related to #
Checklist
- [ ] Checked that the pre-commit linting/style checks pass
- [ ] Included tests that prove the fix is effective or that the new feature works
- [ ] Added necessary documentation (docstrings and/or example notebooks)
- [ ] If you are a pro: each commit corresponds to a relevant logical change
Type of change
- [ ] New feature / enhancement
- [ ] Bug fix
- [ ] Documentation
- [x] Maintenance
- [ ] Other (please specify):
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 80.76%. Comparing base (
98070db
) to head (f5b76e4
).
Additional details and impacted files
@@ Coverage Diff @@
## main #730 +/- ##
=======================================
Coverage 80.76% 80.76%
=======================================
Files 162 162
Lines 46715 46715
Branches 11427 11427
=======================================
Hits 37729 37729
+ Misses 6736 6733 -3
- Partials 2250 2253 +3
Files | Coverage Δ | |
---|---|---|
pytensor/tensor/variable.py | 87.45% <100.00%> (ø) |
@lucianopaz gave a very lukewarm nod to this reversion. If people have strong feelings I'm happy to remove the helpers altogether later.