Skip to content

Commit d3f138c

Browse files
committed
Handle change in behavior np.dtype
1 parent c0de3fc commit d3f138c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pytensor/tensor/type.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,16 @@ def tensor(
783783
**kwargs,
784784
) -> "TensorVariable":
785785
if name is not None:
786-
# Help catching errors with the new tensor API
787-
# Many single letter strings are valid sctypes
788-
if str(name) == "floatX" or (len(str(name)) > 1 and np.dtype(name).type):
789-
raise ValueError(
790-
f"The first and only positional argument of tensor is now `name`. Got {name}.\n"
791-
"This name looks like a dtype, which you should pass as a keyword argument only."
792-
)
786+
try:
787+
# Help catching errors with the new tensor API
788+
# Many single letter strings are valid sctypes
789+
if str(name) == "floatX" or (len(str(name)) > 1 and np.dtype(name).type):
790+
raise ValueError(
791+
f"The first and only positional argument of tensor is now `name`. Got {name}.\n"
792+
"This name looks like a dtype, which you should pass as a keyword argument only."
793+
)
794+
except TypeError:
795+
pass
793796

794797
if dtype is None:
795798
dtype = config.floatX

0 commit comments

Comments
 (0)