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

Add set and add TensorVariable methods for set_subtensor and inc_subtensor operations` (discarded API) #493

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 13, 2023

Uses a similar syntax as JAX, which is considerably less verbose.

import pytensor.tensor as pt

x = pt.matrix()
y = x[0].set(5)  # Equivalent to `y = pt.set_subtensor(x[0], 5)`
y = x[0].add(5)  # Equivalent to `y = pt.inc_subtensor(x[0], 5)`

@ricardoV94 ricardoV94 added the enhancement New feature or request label Nov 13, 2023
@ricardoV94 ricardoV94 requested a review from twiecki November 13, 2023 15:14
@junpenglao
Copy link
Member

Nice

@codecov-commenter
Copy link

Codecov Report

Merging #493 (859b59f) into main (0f802ab) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #493   +/-   ##
=======================================
  Coverage   80.76%   80.77%           
=======================================
  Files         161      161           
  Lines       46080    46084    +4     
  Branches    11258    11258           
=======================================
+ Hits        37218    37224    +6     
+ Misses       6635     6634    -1     
+ Partials     2227     2226    -1     
Files Coverage Δ
pytensor/tensor/variable.py 87.71% <100.00%> (+0.09%) ⬆️

... and 1 file with indirect coverage changes

@ricardoV94 ricardoV94 merged commit 9d5a825 into pymc-devs:main Nov 13, 2023
52 checks passed
@ricardoV94 ricardoV94 deleted the set_subtensor_shortcut branch November 13, 2023 16:21
@ricardoV94 ricardoV94 changed the title Add set and add TensorVariable methods for set_subtensor and inc_subtensor operations` Add set and add TensorVariable methods for set_subtensor and inc_subtensor operations` (discarded API) Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request no releasenotes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants