Skip to content

Commit 8869a9d

Browse files
committed
Removed last variable selection and added test case for no name available
1 parent b7f745e commit 8869a9d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pytensor/graph/basic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,7 @@ def convert_string_keys_to_variables():
611611
f"Found {length_of_nodes_with_matching_names} pytensor variables with name {i}"
612612
)
613613
process_input_to_values[
614-
nodes_with_matching_names[
615-
length_of_nodes_with_matching_names - 1
616-
]
614+
nodes_with_matching_names[0]
617615
] = inputs_to_values[i]
618616
else:
619617
process_input_to_values[i] = inputs_to_values[i]

tests/graph/test_basic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ def test_eval_errors_having_mulitple_variables_same_name(self):
313313
with pytest.raises(Exception, match="Found 2 pytensor variables with name e"):
314314
t.eval({"e": 1})
315315

316+
def test_eval_errors_with_no_name_exists(self):
317+
e = scalars("e")
318+
t = e + 1
319+
t.name = "p"
320+
with pytest.raises(Exception, match="o not found in graph"):
321+
t.eval({"o": 1})
322+
316323

317324
class TestAutoName:
318325
def test_auto_name(self):

0 commit comments

Comments
 (0)