提交 83dea233 authored 作者: Virgile Andreani's avatar Virgile Andreani 提交者: Ricardo Vieira

Remove npy<2 compatibility for OverflowError

上级 80a5c158
......@@ -35,11 +35,6 @@ else:
ndarray_c_version = np.core._multiarray_umath._get_ndarray_c_version() # type: ignore[attr-defined]
# used in tests: the type of error thrown if a value is too large for the specified
# numpy data type is different in numpy 2.x
UintOverflowError = OverflowError if using_numpy_2 else TypeError
# to patch up some of the C code, we need to use these special values...
if using_numpy_2:
numpy_axis_is_none_flag = np.iinfo(np.int32).min # the value of "NPY_RAVEL_AXIS"
......
......@@ -10,7 +10,6 @@ from pytensor.compile import shared
from pytensor.compile.function import function, function_dump
from pytensor.compile.io import In
from pytensor.configdefaults import config
from pytensor.npy_2_compat import UintOverflowError
from pytensor.tensor.type import (
bscalar,
bvector,
......@@ -176,11 +175,11 @@ class TestFunctionIn:
assert np.array_equal(f([2**20], np.ones(1, dtype="int8"), 1), [2])
# Value too big for b, raises OverflowError (in numpy >= 2.0... TypeError in numpy < 2.0)
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
f([3], [312], 1)
# Value too big for c, raises OverflowError
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
f([3], [6], 806)
def test_in_allow_downcast_floatX(self):
......
......@@ -9,7 +9,6 @@ from pytensor.compile.io import In
from pytensor.compile.sharedvalue import shared
from pytensor.configdefaults import config
from pytensor.graph.utils import MissingInputError
from pytensor.npy_2_compat import UintOverflowError
from pytensor.tensor.math import sum as pt_sum
from pytensor.tensor.type import (
bscalar,
......@@ -239,11 +238,11 @@ class TestPfunc:
assert np.all(f([2**20], np.ones(1, dtype="int8"), 1) == 2)
# Value too big for b, raises OverflowError in numpy >= 2.0, TypeError in numpy <2.0
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
f([3], [312], 1)
# Value too big for c, raises OverflowError in numpy >= 2.0, TypeError in numpy <2.0
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
f([3], [6], 806)
def test_param_allow_downcast_floatX(self):
......@@ -329,7 +328,7 @@ class TestPfunc:
g([3], np.array([6], dtype="int16"), 0)
# Value too big for b, raises OverflowError in numpy >= 2.0, TypeError in numpy <2.0
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
g([3], [312], 0)
h = pfunc([a, b, c], (a + b + c)) # Default: allow_input_downcast=None
......@@ -340,7 +339,7 @@ class TestPfunc:
h([3], np.array([6], dtype="int16"), 0)
# Value too big for b, raises OverflowError in numpy >= 2.0, TypeError in numpy <2.0
with pytest.raises(UintOverflowError):
with pytest.raises(OverflowError):
h([3], [312], 0)
def test_allow_downcast_floatX(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论