Skip to content

Commit 5ec2ba2

Browse files
committed
Remove default pytensor function name
1 parent 92c3b49 commit 5ec2ba2

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

pytensor/compile/function/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -275,23 +275,6 @@ def opt_log1p(node):
275275
else:
276276
output_keys = None
277277

278-
if name is None:
279-
# Determine possible file names
280-
source_file = re.sub(r"\.pyc?", ".py", __file__)
281-
compiled_file = source_file + "c"
282-
283-
stack = tb.extract_stack()
284-
idx = len(stack) - 1
285-
286-
last_frame = stack[idx]
287-
if last_frame[0] == source_file or last_frame[0] == compiled_file:
288-
func_frame = stack[idx - 1]
289-
while "pytensor/graph" in func_frame[0] and idx > 0:
290-
idx -= 1
291-
# This can happen if we call var.eval()
292-
func_frame = stack[idx - 1]
293-
name = func_frame[0] + ":" + str(func_frame[1])
294-
295278
if updates is None:
296279
updates = []
297280

tests/compile/function/test_function.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ def test_function_dump():
4747
def test_function_name():
4848
x = vector("x")
4949
func = function([x], x + 1.0)
50-
51-
assert __file__ in func.name
50+
assert func.name is None
51+
func = function([x], x + 1.0, name="my_func")
52+
assert func.name == "my_func"
5253

5354

5455
def test_trust_input():

0 commit comments

Comments
 (0)