Skip to content

Commit c0de3fc

Browse files
committed
Update numpy deprecated imports
1 parent b5c15dc commit c0de3fc

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

pytensor/tensor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _get_vector_length_Constant(op: Op | Variable, var: Constant) -> int:
123123

124124
# isort: on
125125
# Allow accessing numpy constants from pytensor.tensor
126-
from numpy import e, euler_gamma, inf, infty, nan, newaxis, pi
126+
from numpy import e, euler_gamma, inf, nan, newaxis, pi
127127

128128
from pytensor.tensor.basic import *
129129
from pytensor.tensor.blas import batched_dot, batched_tensordot

pytensor/tensor/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4198,7 +4198,7 @@ def expand_dims(
41984198
axis = (axis,)
41994199

42004200
out_ndim = len(axis) + a.ndim
4201-
axis = np.core.numeric.normalize_axis_tuple(axis, out_ndim)
4201+
axis = normalize_axis_tuple(axis, out_ndim)
42024202

42034203
dim_it = iter(range(a.ndim))
42044204
pattern = ["x" if ax in axis else next(dim_it) for ax in range(out_ndim)]

pytensor/tensor/conv/abstract_conv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from math import gcd
99

1010
import numpy as np
11+
from numpy.exceptions import ComplexWarning
1112

1213

1314
try:
@@ -2341,7 +2342,7 @@ def conv(
23412342
bval = _bvalfromboundary("fill")
23422343

23432344
with warnings.catch_warnings():
2344-
warnings.simplefilter("ignore", np.ComplexWarning)
2345+
warnings.simplefilter("ignore", ComplexWarning)
23452346
for b in range(img.shape[0]):
23462347
for g in range(self.num_groups):
23472348
for n in range(output_channel_offset):

pytensor/tensor/extra_ops.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections.abc import Collection, Iterable
22

33
import numpy as np
4-
from numpy.core.multiarray import normalize_axis_index
4+
from numpy.exceptions import AxisError
5+
from numpy.lib.array_utils import normalize_axis_index, normalize_axis_tuple
56

67
import pytensor
78
import pytensor.scalar.basic as ps
@@ -584,9 +585,9 @@ def squeeze(x, axis=None):
584585

585586
# scalar inputs are treated as 1D regarding axis in this `Op`
586587
try:
587-
axis = np.core.numeric.normalize_axis_tuple(axis, ndim=max(1, _x.ndim))
588-
except np.AxisError:
589-
raise np.AxisError(axis, ndim=_x.ndim)
588+
axis = normalize_axis_tuple(axis, ndim=max(1, _x.ndim))
589+
except AxisError:
590+
raise AxisError(axis, ndim=_x.ndim)
590591

591592
if not axis:
592593
# Nothing to do

pytensor/tensor/slinalg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import numpy as np
88
import scipy.linalg
9+
from numpy.exceptions import ComplexWarning
910

1011
import pytensor
1112
import pytensor.tensor as pt
@@ -633,7 +634,7 @@ def perform(self, node, inputs, outputs):
633634
Y = U.dot(V.T.dot(gA).dot(U) * X).dot(V.T)
634635

635636
with warnings.catch_warnings():
636-
warnings.simplefilter("ignore", np.ComplexWarning)
637+
warnings.simplefilter("ignore", ComplexWarning)
637638
out[0] = Y.astype(A.dtype)
638639

639640

tests/tensor/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_memmap(self):
5151
path = Variable(Generic(), None)
5252
x = load(path, "int32", (None,), mmap_mode="c")
5353
fn = function([path], x)
54-
assert type(fn(self.filename)) == np.core.memmap
54+
assert type(fn(self.filename)) == np.memmap
5555

5656
def teardown_method(self):
5757
os.remove(os.path.join(pytensor.config.compiledir, "_test.npy"))

0 commit comments

Comments
 (0)