Skip to content

Commit d108f19

Browse files
committed
Fix numpy DeprecationWarning when converting integers to PyTensor Constants
1 parent 0b632bd commit d108f19

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pytensor/misc/safe_asarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _asarray(a, dtype, order=None):
3232
if str(dtype) == "floatX":
3333
dtype = config.floatX
3434
dtype = np.dtype(dtype) # Convert into dtype object.
35-
rval = np.asarray(a, dtype=dtype, order=order)
35+
rval = np.asarray(a, order=order).astype(dtype)
3636
# Note that dtype comparison must be done by comparing their `num`
3737
# attribute. One cannot assume that two identical data types are pointers
3838
# towards the same object (e.g. under Windows this appears not to be the

tests/tensor/test_basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import itertools
2+
import warnings
23
from functools import partial
34
from tempfile import mkstemp
45

0 commit comments

Comments
 (0)