Skip to content

Commit

Permalink
Fix typo in __setitem__ error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoV94 authored and lucianopaz committed Oct 31, 2024
1 parent 4f7d709 commit 03e5f77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pytensor/tensor/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def is_empty_array(val):

def __setitem__(self, key, value):
raise TypeError(
"TensorVariable does not support item assignment. Use the output of `set` or `add` instead."
"TensorVariable does not support item assignment. Use the output of `x[idx].set` or `x[idx].inc` instead."
)

def take(self, indices, axis=None, mode="raise"):
Expand Down
3 changes: 2 additions & 1 deletion tests/tensor/test_variable.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from copy import copy

import numpy as np
Expand Down Expand Up @@ -444,7 +445,7 @@ def test_set_inc(self):
def test_set_item_error(self):
x = matrix("x")

msg = "Use the output of `set` or `add` instead."
msg = re.escape("Use the output of `x[idx].set` or `x[idx].inc` instead.")
with pytest.raises(TypeError, match=msg):
x[0] = 5
with pytest.raises(TypeError, match=msg):
Expand Down

0 comments on commit 03e5f77

Please sign in to comment.