Skip to content
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

Change behavior of helper set/inc to act on an indexed variable directly #730

Merged
merged 1 commit into from
May 10, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Apr 25, 2024

Description

Reverting back to the option first suggested in #493 and then overridden in #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

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@ricardoV94 ricardoV94 force-pushed the revert_set_inc_behavior branch from bc25e85 to f5b76e4 Compare April 25, 2024 18:16
Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.76%. Comparing base (98070db) to head (f5b76e4).

Additional details and impacted files

Impacted file tree graph

@@           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%> (ø)

... and 3 files with indirect coverage changes

@ricardoV94
Copy link
Member Author

@lucianopaz gave a very lukewarm nod to this reversion. If people have strong feelings I'm happy to remove the helpers altogether later.

@ricardoV94 ricardoV94 merged commit db73461 into pymc-devs:main May 10, 2024
55 checks passed
@ricardoV94 ricardoV94 changed the title Change behavior of helper set/inc to act on an indexed variable directly Change behavior of helper set/inc to act on an indexed variable directly May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant