@@ -824,36 +824,46 @@ def compress(self, a, axis=None):
824
824
"""Return selected slices only."""
825
825
return pt .extra_ops .compress (self , a , axis = axis )
826
826
827
- def set (self , idx , y , ** kwargs ):
828
- """Return a copy of self with the indexed values set to y.
827
+ def set (self , y , ** kwargs ):
828
+ """Return a copy of the variable indexed by self with the indexed values set to y.
829
829
830
- Equivalent to set_subtensor(self[idx], y). See docstrings for kwargs.
830
+ Equivalent to set_subtensor(self, y). See docstrings for kwargs.
831
+
832
+ Raises
833
+ ------
834
+ TypeError:
835
+ If self is not the result of a subtensor operation
831
836
832
837
Examples
833
838
--------
834
839
>>> import pytensor.tensor as pt
835
840
>>>
836
841
>>> x = pt.ones((3,))
837
- >>> out = x.set(1, 2)
842
+ >>> out = x[1] .set(2)
838
843
>>> out.eval() # array([1., 2., 1.])
839
844
"""
840
- return pt .subtensor .set_subtensor (self [idx ], y , ** kwargs )
845
+ return pt .subtensor .set_subtensor (self , y , ** kwargs )
846
+
847
+ def inc (self , y , ** kwargs ):
848
+ """Return a copy of the variable indexed by self with the indexed values incremented by y.
841
849
842
- def inc (self , idx , y , ** kwargs ):
843
- """Return a copy of self with the indexed values incremented by y.
850
+ Equivalent to inc_subtensor(self, y). See docstrings for kwargs.
844
851
845
- Equivalent to inc_subtensor(self[idx], y). See docstrings for kwargs.
852
+ Raises
853
+ ------
854
+ TypeError:
855
+ If self is not the result of a subtensor operation
846
856
847
857
Examples
848
858
--------
849
859
850
860
>>> import pytensor.tensor as pt
851
861
>>>
852
862
>>> x = pt.ones((3,))
853
- >>> out = x.inc(1, 2)
863
+ >>> out = x[1] .inc(2)
854
864
>>> out.eval() # array([1., 3., 1.])
855
865
"""
856
- return pt .inc_subtensor (self [ idx ] , y , ** kwargs )
866
+ return pt .inc_subtensor (self , y , ** kwargs )
857
867
858
868
859
869
class TensorVariable (
0 commit comments