fix Wrong TypeError in numpy_native

This commit is contained in:
wangrao 2020-12-21 15:55:48 +08:00
parent dc2f33d0d1
commit 2fb3f0ef4f
2 changed files with 3 additions and 3 deletions

View File

@ -78,7 +78,7 @@ def _check_axes_range(axes, ndim):
f"Lower bound {low} and upper bound {up} of axes are not allowed.")
if isinstance(axes, int):
if axes < low or axes > up:
raise TypeError(
raise ValueError(
f"axis {axes} is out of bounds for tensor of dimension {ndim}.")
return axes if axes >= 0 else axes + ndim
new_axes = []
@ -87,7 +87,7 @@ def _check_axes_range(axes, ndim):
raise TypeError(
f"int in tuple or list expected, but got {type(item)}.")
if item < low or item > up:
raise TypeError(
raise ValueError(
f"axis {item} in {axes} is out of bounds for tensor of dimension {ndim}.")
new_axes.append(item if item >= 0 else item + ndim)
return tuple(new_axes)

View File

@ -582,7 +582,7 @@ def test_asarray_exception():
def test_swapaxes_exception():
with pytest.raises(TypeError):
with pytest.raises(ValueError):
mnp.swapaxes(mnp.ones((3, 3)), 1, 10)