From 7bb114c343a301fe643360b9cdc9faae8407b514 Mon Sep 17 00:00:00 2001 From: Ricardo Vieira Date: Thu, 9 Mar 2023 17:23:36 +0100 Subject: [PATCH] Fix numpy DeprecationWarning when converting integers to PyTensor Constants --- pytensor/misc/safe_asarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytensor/misc/safe_asarray.py b/pytensor/misc/safe_asarray.py index 13fce4d7b1..b6ef69c0a8 100644 --- a/pytensor/misc/safe_asarray.py +++ b/pytensor/misc/safe_asarray.py @@ -32,7 +32,7 @@ def _asarray(a, dtype, order=None): if str(dtype) == "floatX": dtype = config.floatX dtype = np.dtype(dtype) # Convert into dtype object. - rval = np.asarray(a, dtype=dtype, order=order) + rval = np.asarray(a, order=order).astype(dtype) # Note that dtype comparison must be done by comparing their `num` # attribute. One cannot assume that two identical data types are pointers # towards the same object (e.g. under Windows this appears not to be the