mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[ci, 3.13] skip dynamo-xpass'd numpy tests in numpy >= 2.0 (#141862)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141862 Approved by: https://github.com/StrongerXi, https://github.com/atalman ghstack dependencies: #141409, #142003, #141572, #141577, #141605, #141621, #141623, #141673, #141674, #141858
This commit is contained in:
parent
76d1047629
commit
abc4111348
|
|
@ -16,7 +16,7 @@ from torch.testing._internal.common_utils import (
|
|||
skipIfTorchDynamo,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ IS_PYPY = False
|
|||
@skipif(numpy.__version__ < "1.24", reason="numpy.dlpack is new in numpy 1.23")
|
||||
@instantiate_parametrized_tests
|
||||
class TestDLPack(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="pytorch seems to handle refcounts differently")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch seems to handle refcounts differently")
|
||||
@skipif(IS_PYPY, reason="PyPy can't get refcounts.")
|
||||
def test_dunder_dlpack_refcount(self):
|
||||
x = np.arange(5)
|
||||
|
|
@ -55,7 +55,7 @@ class TestDLPack(TestCase):
|
|||
with pytest.raises(RuntimeError):
|
||||
x.__dlpack__(stream=1)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch seems to handle refcounts differently")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch seems to handle refcounts differently")
|
||||
@skipif(IS_PYPY, reason="PyPy can't get refcounts.")
|
||||
def test_from_dlpack_refcount(self):
|
||||
x = np.arange(5)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from torch.testing._internal.common_utils import (
|
|||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xfailIfTorchDynamo,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ class TestMisc(TestCase):
|
|||
assert bool(np.dtype("f8"))
|
||||
assert bool(np.dtype("i8"))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="No keyword arg for dtype ctor.")
|
||||
@xpassIfTorchDynamo_np # (reason="No keyword arg for dtype ctor.")
|
||||
def test_keyword_argument(self):
|
||||
# test for https://github.com/numpy/numpy/pull/16574#issuecomment-642660971
|
||||
assert np.dtype(dtype=np.float64) == np.dtype(np.float64)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -212,7 +212,7 @@ class TestMisc(TestCase):
|
|||
# This test may fail on some platforms
|
||||
assert len(w) == 0
|
||||
|
||||
@xpassIfTorchDynamo # (reason="None of nmant, minexp, maxexp is implemented.")
|
||||
@xpassIfTorchDynamo_np # (reason="None of nmant, minexp, maxexp is implemented.")
|
||||
def test_plausible_finfo(self):
|
||||
# Assert that finfo returns reasonable results for all types
|
||||
for ftype in (
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from torch.testing._internal.common_utils import (
|
|||
skipIfTorchDynamo,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ class TestIndexing(TestCase):
|
|||
b[(Ellipsis,)] = 2
|
||||
assert_equal(b, 2)
|
||||
|
||||
@xpassIfTorchDynamo # 'torch_.np.array() does not have base attribute.
|
||||
@xpassIfTorchDynamo_np # 'torch_.np.array() does not have base attribute.
|
||||
def test_ellipsis_index_2(self):
|
||||
a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
|
||||
assert_(a[...] is not a)
|
||||
|
|
@ -421,7 +421,7 @@ class TestIndexing(TestCase):
|
|||
# Unlike the non nd-index:
|
||||
assert_(arr[index,].shape != (1,))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: low-prio behaviour to support")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: low-prio behaviour to support")
|
||||
def test_broken_sequence_not_nd_index(self):
|
||||
# See https://github.com/numpy/numpy/issues/5063
|
||||
# If we have an object which claims to be a sequence, but fails
|
||||
|
|
@ -588,7 +588,7 @@ class TestBroadcastedAssignments(TestCase):
|
|||
|
||||
|
||||
class TestFancyIndexingCast(TestCase):
|
||||
@xpassIfTorchDynamo # (
|
||||
@xpassIfTorchDynamo_np # (
|
||||
# reason="XXX: low-prio to support assigning complex values on floating arrays"
|
||||
# )
|
||||
def test_boolean_index_cast_assign(self):
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from torch.testing._internal.common_utils import (
|
|||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xfailIfTorchDynamo,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ def _aligned_zeros(shape, dtype=float, order="C", align=None):
|
|||
return data
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: flags")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: flags")
|
||||
@instantiate_parametrized_tests
|
||||
class TestFlag(TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -307,7 +307,7 @@ class TestFlag(TestCase):
|
|||
assert_(a.flags.aligned)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: hash")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: hash")
|
||||
class TestHash(TestCase):
|
||||
# see #3793
|
||||
def test_int(self):
|
||||
|
|
@ -345,7 +345,7 @@ class TestHash(TestCase):
|
|||
)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: hash")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: hash")
|
||||
class TestAttributes(TestCase):
|
||||
def setUp(self):
|
||||
self.one = np.arange(10)
|
||||
|
|
@ -536,7 +536,7 @@ class TestArrayConstruction(TestCase):
|
|||
d[1] = 3
|
||||
assert_array_equal(e, [1, 3, 3])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="order='F'")
|
||||
def test_array_copy_false_2(self):
|
||||
d = np.array([1, 2, 3])
|
||||
e = np.array(d, copy=False, order="F")
|
||||
|
|
@ -1335,7 +1335,7 @@ class TestBool(TestCase):
|
|||
assert_equal(d[::2].sum(), d[::2].size)
|
||||
# assert_equal(d[::-2].sum(), d[::-2].size)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="frombuffer")
|
||||
@xpassIfTorchDynamo_np # (reason="frombuffer")
|
||||
def test_sum_2(self):
|
||||
d = np.frombuffer(b"\xff\xff" * 100, dtype=bool)
|
||||
assert_equal(d.sum(), d.size)
|
||||
|
|
@ -1415,7 +1415,7 @@ class TestBool(TestCase):
|
|||
class TestMethods(TestCase):
|
||||
sort_kinds = ["quicksort", "heapsort", "stable"]
|
||||
|
||||
@xpassIfTorchDynamo # (reason="all(..., where=...)")
|
||||
@xpassIfTorchDynamo_np # (reason="all(..., where=...)")
|
||||
def test_all_where(self):
|
||||
a = np.array([[True, False, True], [False, False, False], [True, True, True]])
|
||||
wh_full = np.array(
|
||||
|
|
@ -1435,7 +1435,7 @@ class TestMethods(TestCase):
|
|||
assert_equal(a.all(where=False), True)
|
||||
assert_equal(np.all(a, where=False), True)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="any(..., where=...)")
|
||||
@xpassIfTorchDynamo_np # (reason="any(..., where=...)")
|
||||
def test_any_where(self):
|
||||
a = np.array([[True, False, True], [False, False, False], [True, True, True]])
|
||||
wh_full = np.array(
|
||||
|
|
@ -1456,7 +1456,7 @@ class TestMethods(TestCase):
|
|||
assert_equal(a.any(where=False), False)
|
||||
assert_equal(np.any(a, where=False), False)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: compress")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: compress")
|
||||
def test_compress(self):
|
||||
tgt = [[5, 6, 7, 8, 9]]
|
||||
arr = np.arange(10).reshape(2, 5)
|
||||
|
|
@ -1497,7 +1497,7 @@ class TestMethods(TestCase):
|
|||
assert out is ret
|
||||
assert_equal(out[()], 20)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="choose(..., mode=...) not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="choose(..., mode=...) not implemented")
|
||||
def test_choose_2(self):
|
||||
# gh-6272 check overlap on out
|
||||
x = np.arange(5)
|
||||
|
|
@ -1548,7 +1548,7 @@ class TestMethods(TestCase):
|
|||
A = m_rect.repeat(2, axis=1)
|
||||
assert_equal(A, [[1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6]])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="reshape(..., order='F')")
|
||||
@xpassIfTorchDynamo_np # (reason="reshape(..., order='F')")
|
||||
def test_reshape(self):
|
||||
arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
|
||||
|
||||
|
|
@ -1607,7 +1607,7 @@ class TestMethods(TestCase):
|
|||
b = np.sort(a)
|
||||
assert_equal(b, np.flip(a), msg)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="sort complex")
|
||||
@xpassIfTorchDynamo_np # (reason="sort complex")
|
||||
def test_sort_complex_nans(self):
|
||||
# check complex
|
||||
msg = "Test complex sort order with nans"
|
||||
|
|
@ -1652,7 +1652,7 @@ class TestMethods(TestCase):
|
|||
c.sort(kind=kind)
|
||||
assert_equal(c, a, msg)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="sort complex")
|
||||
@xpassIfTorchDynamo_np # (reason="sort complex")
|
||||
@parametrize("dtype", [np.float32, np.float64])
|
||||
@parametrize("part", ["real", "imag"])
|
||||
def test_sort_complex(self, part, dtype):
|
||||
|
|
@ -1801,7 +1801,7 @@ class TestMethods(TestCase):
|
|||
msg = f"byte-swapped complex argsort, dtype={dt}"
|
||||
assert_equal(arr.argsort(), np.arange(len(arr), dtype=np.intp), msg)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="argsort axis TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="argsort axis TODO")
|
||||
def test_argsort_axis(self):
|
||||
# check axis handling. This should be the same for all type
|
||||
# specific argsorts, so we only check it for one type and one kind
|
||||
|
|
@ -1838,7 +1838,7 @@ class TestMethods(TestCase):
|
|||
a = np.array(["aaaaaaaaa" for i in range(100)], dtype=np.str_)
|
||||
assert_equal(a.argsort(kind="m"), r)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: searchsorted with nans differs in pytorch")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: searchsorted with nans differs in pytorch")
|
||||
@parametrize(
|
||||
"a",
|
||||
[
|
||||
|
|
@ -1910,7 +1910,7 @@ class TestMethods(TestCase):
|
|||
b = a.searchsorted([0, 1, 2], "right")
|
||||
assert_equal(b, [0, 2, 2])
|
||||
|
||||
@xpassIfTorchDynamo # (
|
||||
@xpassIfTorchDynamo_np # (
|
||||
# reason="RuntimeError: self.storage_offset() must be divisible by 8"
|
||||
# )
|
||||
def test_searchsorted_unaligned_array(self):
|
||||
|
|
@ -1953,7 +1953,7 @@ class TestMethods(TestCase):
|
|||
b = a.searchsorted(a, "right")
|
||||
assert_equal(b, out + 1)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="ndarray ctor")
|
||||
@xpassIfTorchDynamo_np # (reason="ndarray ctor")
|
||||
def test_searchsorted_type_specific_2(self):
|
||||
# Test all type specific binary search functions
|
||||
types = "".join((np.typecodes["AllInteger"], np.typecodes["AllFloat"], "?"))
|
||||
|
|
@ -1989,7 +1989,7 @@ class TestMethods(TestCase):
|
|||
# assert_raises(ValueError, np.searchsorted, a, 0, sorter=[-1, 0, 1, 2, 3])
|
||||
# assert_raises(ValueError, np.searchsorted, a, 0, sorter=[4, 0, -1, 2, 3])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="self.storage_offset() must be divisible by 8")
|
||||
@xpassIfTorchDynamo_np # (reason="self.storage_offset() must be divisible by 8")
|
||||
def test_searchsorted_with_sorter(self):
|
||||
a = np.random.rand(300)
|
||||
s = a.argsort()
|
||||
|
|
@ -2064,7 +2064,7 @@ class TestMethods(TestCase):
|
|||
b = a.searchsorted(a, "right", s)
|
||||
assert_equal(b, out + 1)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO argpartition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO argpartition")
|
||||
@parametrize("dtype", "efdFDBbhil?")
|
||||
def test_argpartition_out_of_range(self, dtype):
|
||||
# Test out of range values in kth raise an error, gh-5469
|
||||
|
|
@ -2072,7 +2072,7 @@ class TestMethods(TestCase):
|
|||
assert_raises(ValueError, d.argpartition, 10)
|
||||
assert_raises(ValueError, d.argpartition, -11)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
@parametrize("dtype", "efdFDBbhil?")
|
||||
def test_partition_out_of_range(self, dtype):
|
||||
# Test out of range values in kth raise an error, gh-5469
|
||||
|
|
@ -2080,7 +2080,7 @@ class TestMethods(TestCase):
|
|||
assert_raises(ValueError, d.partition, 10)
|
||||
assert_raises(ValueError, d.partition, -11)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO argpartition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO argpartition")
|
||||
def test_argpartition_integer(self):
|
||||
# Test non-integer values in kth raise an error/
|
||||
d = np.arange(10)
|
||||
|
|
@ -2090,7 +2090,7 @@ class TestMethods(TestCase):
|
|||
d_obj = np.arange(10, dtype=object)
|
||||
assert_raises(TypeError, d_obj.argpartition, 9.0)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
def test_partition_integer(self):
|
||||
# Test out of range values in kth raise an error, gh-5469
|
||||
d = np.arange(10)
|
||||
|
|
@ -2100,7 +2100,7 @@ class TestMethods(TestCase):
|
|||
d_obj = np.arange(10, dtype=object)
|
||||
assert_raises(TypeError, d_obj.partition, 9.0)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
@parametrize("kth_dtype", "Bbhil")
|
||||
def test_partition_empty_array(self, kth_dtype):
|
||||
# check axis handling for multidimensional empty arrays
|
||||
|
|
@ -2113,7 +2113,7 @@ class TestMethods(TestCase):
|
|||
msg = "test empty array partition with axis=None"
|
||||
assert_equal(np.partition(a, kth, axis=None), a.ravel(), msg)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO argpartition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO argpartition")
|
||||
@parametrize("kth_dtype", "Bbhil")
|
||||
def test_argpartition_empty_array(self, kth_dtype):
|
||||
# check axis handling for multidimensional empty arrays
|
||||
|
|
@ -2132,7 +2132,7 @@ class TestMethods(TestCase):
|
|||
msg,
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
def test_partition(self):
|
||||
d = np.arange(10)
|
||||
assert_raises(TypeError, np.partition, d, 2, kind=1)
|
||||
|
|
@ -2393,7 +2393,7 @@ class TestMethods(TestCase):
|
|||
)
|
||||
prev = k + 1
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
def test_partition_iterative(self):
|
||||
d = np.arange(17)
|
||||
kth = (0, 1, 2, 429, 231)
|
||||
|
|
@ -2460,7 +2460,7 @@ class TestMethods(TestCase):
|
|||
for i in range(d0.shape[1]):
|
||||
self.assert_partitioned(p[:, i], kth)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
def test_partition_fuzz(self):
|
||||
# a few rounds of random data testing
|
||||
for j in range(10, 30):
|
||||
|
|
@ -2477,7 +2477,7 @@ class TestMethods(TestCase):
|
|||
err_msg=f"data: {d!r}\n kth: {kth!r}",
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO partition")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO partition")
|
||||
@parametrize("kth_dtype", "Bbhil")
|
||||
def test_argpartition_gh5524(self, kth_dtype):
|
||||
# A test for functionality of argpartition on lists.
|
||||
|
|
@ -2486,7 +2486,7 @@ class TestMethods(TestCase):
|
|||
p = np.argpartition(d, kth)
|
||||
self.assert_partitioned(np.array(d)[p], [1])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO order='F'")
|
||||
def test_flatten(self):
|
||||
x0 = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
|
||||
x1 = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], np.int32)
|
||||
|
|
@ -2629,7 +2629,7 @@ class TestMethods(TestCase):
|
|||
a.dot(b=b, out=c)
|
||||
assert_equal(c, np.dot(a, b))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="_aligned_zeros")
|
||||
@xpassIfTorchDynamo_np # (reason="_aligned_zeros")
|
||||
def test_dot_out_mem_overlap(self):
|
||||
np.random.seed(1)
|
||||
|
||||
|
|
@ -2651,7 +2651,7 @@ class TestMethods(TestCase):
|
|||
assert_raises(ValueError, np.dot, a, b, out=b[::2])
|
||||
assert_raises(ValueError, np.dot, a, b, out=b.T)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: overlapping memor in matmul")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: overlapping memor in matmul")
|
||||
def test_matmul_out(self):
|
||||
# overlapping memory
|
||||
a = np.arange(18).reshape(2, 3, 3)
|
||||
|
|
@ -2778,7 +2778,7 @@ class TestMethods(TestCase):
|
|||
bad_array = [1, 2, 3]
|
||||
assert_raises(TypeError, np.put, bad_array, [0, 2], 5)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement order='F'")
|
||||
def test_ravel(self):
|
||||
a = np.array([[0, 1], [2, 3]])
|
||||
assert_equal(a.ravel(), [0, 1, 2, 3])
|
||||
|
|
@ -3189,7 +3189,7 @@ class TestArgmaxArgminCommon(TestCase):
|
|||
with pytest.raises(ValueError):
|
||||
method(arr.T, axis=axis, out=wrong_outarray, keepdims=True)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement choose")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement choose")
|
||||
@parametrize("method", ["max", "min"])
|
||||
def test_all(self, method):
|
||||
a = np.random.normal(0, 1, (4, 5, 6, 7, 8))
|
||||
|
|
@ -3472,7 +3472,7 @@ class TestArgmin(TestCase):
|
|||
|
||||
|
||||
class TestMinMax(TestCase):
|
||||
@xpassIfTorchDynamo
|
||||
@xpassIfTorchDynamo_np
|
||||
def test_scalar(self):
|
||||
assert_raises(np.AxisError, np.amax, 1, 1)
|
||||
assert_raises(np.AxisError, np.amin, 1, 1)
|
||||
|
|
@ -3578,7 +3578,7 @@ class TestClip(TestCase):
|
|||
assert_array_equal(result, expected)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestCompress(TestCase):
|
||||
def test_axis(self):
|
||||
tgt = [[5, 6, 7, 8, 9]]
|
||||
|
|
@ -3602,7 +3602,7 @@ class TestCompress(TestCase):
|
|||
assert_equal(out, 1)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
@instantiate_parametrized_tests
|
||||
class TestPutmask(TestCase):
|
||||
def tst_basic(self, x, T, mask, val):
|
||||
|
|
@ -3706,14 +3706,14 @@ class TestTake(TestCase):
|
|||
assert_raises(IndexError, np.take, x, [-3], axis=0)
|
||||
assert_array_equal(np.take(x, [-1], axis=0)[0], x[1])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: take(..., mode='clip')")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: take(..., mode='clip')")
|
||||
def test_clip(self):
|
||||
x = np.random.random(24) * 100
|
||||
x = np.reshape(x, (2, 3, 4))
|
||||
assert_array_equal(np.take(x, [-1], axis=0, mode="clip")[0], x[0])
|
||||
assert_array_equal(np.take(x, [2], axis=0, mode="clip")[0], x[1])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: take(..., mode='wrap')")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: take(..., mode='wrap')")
|
||||
def test_wrap(self):
|
||||
x = np.random.random(24) * 100
|
||||
x = np.reshape(x, (2, 3, 4))
|
||||
|
|
@ -3721,7 +3721,7 @@ class TestTake(TestCase):
|
|||
assert_array_equal(np.take(x, [2], axis=0, mode="wrap")[0], x[0])
|
||||
assert_array_equal(np.take(x, [3], axis=0, mode="wrap")[0], x[1])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: take(mode='wrap')")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: take(mode='wrap')")
|
||||
def test_out_overlap(self):
|
||||
# gh-6272 check overlap on out
|
||||
x = np.arange(5)
|
||||
|
|
@ -3738,7 +3738,7 @@ class TestTake(TestCase):
|
|||
assert ret is out
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
@instantiate_parametrized_tests
|
||||
class TestLexsort(TestCase):
|
||||
@parametrize(
|
||||
|
|
@ -4298,7 +4298,7 @@ class TestIO(TestCase):
|
|||
assert_array_equal(res, expected)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
@instantiate_parametrized_tests
|
||||
class TestFromBuffer(TestCase):
|
||||
@parametrize(
|
||||
|
|
@ -4311,7 +4311,7 @@ class TestFromBuffer(TestCase):
|
|||
buf = x.tobytes()
|
||||
assert_array_equal(np.frombuffer(buf, dtype=dt), x.flat)
|
||||
|
||||
# @xpassIfTorchDynamo
|
||||
# @xpassIfTorchDynamo_np
|
||||
@parametrize(
|
||||
"obj", [np.arange(10), subtest("12345678", decorators=[xfailIfTorchDynamo])]
|
||||
)
|
||||
|
|
@ -4688,7 +4688,7 @@ class TestStats(TestCase):
|
|||
with assert_raises(np.AxisError):
|
||||
np.arange(10).mean(axis=2)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="implement mean(..., where=...)")
|
||||
@xpassIfTorchDynamo_np # (reason="implement mean(..., where=...)")
|
||||
def test_mean_where(self):
|
||||
a = np.arange(16).reshape((4, 4))
|
||||
wh_full = np.array(
|
||||
|
|
@ -4776,7 +4776,7 @@ class TestStats(TestCase):
|
|||
with assert_raises(np.AxisError):
|
||||
np.arange(10).var(axis=2)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="implement var(..., where=...)")
|
||||
@xpassIfTorchDynamo_np # (reason="implement var(..., where=...)")
|
||||
def test_var_where(self):
|
||||
a = np.arange(25).reshape((5, 5))
|
||||
wh_full = np.array(
|
||||
|
|
@ -4821,7 +4821,7 @@ class TestStats(TestCase):
|
|||
res = _std(mat, axis=axis)
|
||||
assert_almost_equal(res, tgt)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="implement std(..., where=...)")
|
||||
@xpassIfTorchDynamo_np # (reason="implement std(..., where=...)")
|
||||
def test_std_where(self):
|
||||
a = np.arange(25).reshape((5, 5))[::-1]
|
||||
whf = np.array(
|
||||
|
|
@ -4891,7 +4891,7 @@ class TestVdot(TestCase):
|
|||
assert_(np.isscalar(res))
|
||||
assert_equal(np.vdot(b, b), True)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="implement order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="implement order='F'")
|
||||
def test_vdot_array_order(self):
|
||||
a = np.array([[1, 2], [3, 4]], order="C")
|
||||
b = np.array([[1, 2], [3, 4]], order="F")
|
||||
|
|
@ -4917,7 +4917,7 @@ class TestVdot(TestCase):
|
|||
assert_equal(np.vdot(a, b.copy()), np.vdot(a.flatten(), b.flatten()))
|
||||
assert_equal(np.vdot(a.copy(), b), np.vdot(a.flatten(), b.flatten()))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="implement order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="implement order='F'")
|
||||
def test_vdot_uncontiguous_2(self):
|
||||
# test order='F' separately
|
||||
for size in [2, 1000]:
|
||||
|
|
@ -5129,7 +5129,7 @@ class TestDot(TestCase):
|
|||
r = np.empty((1024, 32), dtype=int)
|
||||
assert_raises(ValueError, dot, f, v, r)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO order='F'")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO order='F'")
|
||||
def test_dot_array_order(self):
|
||||
a = np.array([[1, 2], [3, 4]], order="C")
|
||||
b = np.array([[1, 2], [3, 4]], order="F")
|
||||
|
|
@ -5276,7 +5276,7 @@ class MatmulCommon:
|
|||
res = self.matmul(*arg)
|
||||
assert_(res.dtype == dt)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="no scalars")
|
||||
@xpassIfTorchDynamo_np # (reason="no scalars")
|
||||
def test_result_types_2(self):
|
||||
# in numpy, vector vector returns scalars
|
||||
# we return a 0D array instead
|
||||
|
|
@ -5654,7 +5654,7 @@ class TestMatmulOperator(MatmulCommon, TestCase):
|
|||
(RuntimeError, TypeError, ValueError), self.matmul, np.int8(5), np.int8(5)
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="torch supports inplace matmul, and so do we")
|
||||
@xpassIfTorchDynamo_np # (reason="torch supports inplace matmul, and so do we")
|
||||
@skipif(numpy.__version__ >= "1.26", reason="This is fixed in numpy 1.26")
|
||||
def test_matmul_inplace(self):
|
||||
# It would be nice to support in-place matmul eventually, but for now
|
||||
|
|
@ -5672,7 +5672,7 @@ class TestMatmulOperator(MatmulCommon, TestCase):
|
|||
assert_raises(TypeError, operator.imatmul, a, b)
|
||||
assert_raises(TypeError, exec, "a @= b", globals(), locals())
|
||||
|
||||
@xpassIfTorchDynamo # (reason="matmul_axes")
|
||||
@xpassIfTorchDynamo_np # (reason="matmul_axes")
|
||||
def test_matmul_axes(self):
|
||||
a = np.arange(3 * 4 * 5).reshape(3, 4, 5)
|
||||
c = np.matmul(a, a, axes=[(-2, -1), (-1, -2), (1, 2)])
|
||||
|
|
@ -5849,7 +5849,7 @@ class TestRepeat(TestCase):
|
|||
NEIGH_MODE = {"zero": 0, "one": 1, "constant": 2, "circular": 3, "mirror": 4}
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestWarnings(TestCase):
|
||||
def test_complex_warning(self):
|
||||
x = np.array([1, 2])
|
||||
|
|
@ -6005,13 +6005,13 @@ class TestPEP3118Dtype(TestCase):
|
|||
self._check("i:f0:", [("f0", "i")])
|
||||
|
||||
|
||||
# NOTE: xpassIfTorchDynamo below
|
||||
# NOTE: xpassIfTorchDynamo_np below
|
||||
# 1. TODO: torch._numpy does not handle/model _CopyMode
|
||||
# 2. order= keyword not supported (probably won't be)
|
||||
# 3. Under TEST_WITH_TORCHDYNAMO many of these make it through due
|
||||
# to a graph break leaving the _CopyMode to only be handled by numpy.
|
||||
@skipif(numpy.__version__ < "1.23", reason="CopyMode is new in NumPy 1.22")
|
||||
@xpassIfTorchDynamo
|
||||
@xpassIfTorchDynamo_np
|
||||
@instantiate_parametrized_tests
|
||||
class TestArrayCreationCopyArgument(TestCase):
|
||||
class RaiseOnBool:
|
||||
|
|
@ -6323,7 +6323,7 @@ class TestArrayInterface(TestCase):
|
|||
|
||||
|
||||
class TestDelMisc(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
def test_flat_element_deletion(self):
|
||||
it = np.ones(3).flat
|
||||
try:
|
||||
|
|
@ -6703,7 +6703,7 @@ class TestHashing(TestCase):
|
|||
|
||||
|
||||
class TestFormat(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
def test_0d(self):
|
||||
a = np.array(np.pi)
|
||||
assert_equal(f"{a:0.3g}", "3.14")
|
||||
|
|
@ -6736,7 +6736,7 @@ class TestWritebackIfCopy(TestCase):
|
|||
res = np.argmin(mat, 0, out=out)
|
||||
assert_equal(res, range(5))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: place()")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: place()")
|
||||
def test_insert_noncontiguous(self):
|
||||
a = np.arange(6).reshape(2, 3).T # force non-c-contiguous
|
||||
# uses arr_insert
|
||||
|
|
@ -6751,7 +6751,7 @@ class TestWritebackIfCopy(TestCase):
|
|||
np.put(a, [0, 2], [44, 55])
|
||||
assert_equal(a, np.array([[44, 3], [55, 4], [2, 5]]))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: putmask()")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: putmask()")
|
||||
def test_putmask_noncontiguous(self):
|
||||
a = np.arange(6).reshape(2, 3).T # force non-c-contiguous
|
||||
# uses arr_putmask
|
||||
|
|
@ -6771,7 +6771,7 @@ class TestWritebackIfCopy(TestCase):
|
|||
np.choose(a, choices, out=out, mode="raise")
|
||||
assert_equal(out, np.array([[10, -10, 10], [-10, 10, -10], [10, -10, 10]]))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: ndarray.flat")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: ndarray.flat")
|
||||
def test_flatiter__array__(self):
|
||||
a = np.arange(9).reshape(3, 3)
|
||||
b = a.T.flat
|
||||
|
|
@ -6815,7 +6815,7 @@ class TestArange(TestCase):
|
|||
assert_raises(TypeError, np.arange, step=3)
|
||||
assert_raises(TypeError, np.arange, dtype="int64")
|
||||
|
||||
@xpassIfTorchDynamo # (reason="weird arange signature (optionals before required args)")
|
||||
@xpassIfTorchDynamo_np # (reason="weird arange signature (optionals before required args)")
|
||||
def test_require_range_2(self):
|
||||
assert_raises(TypeError, np.arange, start=4)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from torch.testing._internal.common_utils import (
|
|||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xfailIfTorchDynamo,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ class TestNonarrayArgs(TestCase):
|
|||
tgt = [2, 5, 2, 3, 7, 2, 2]
|
||||
assert_equal(out, tgt)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO implement compress(...)")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO implement compress(...)")
|
||||
def test_compress(self):
|
||||
arr = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]
|
||||
tgt = [[5, 6, 7, 8, 9]]
|
||||
|
|
@ -205,7 +205,7 @@ class TestNonarrayArgs(TestCase):
|
|||
s = np.float64(1.0)
|
||||
assert_(isinstance(s.round(), (np.float64, np.ndarray)))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="scalar instances")
|
||||
@xpassIfTorchDynamo_np # (reason="scalar instances")
|
||||
@parametrize(
|
||||
"dtype",
|
||||
[
|
||||
|
|
@ -234,14 +234,14 @@ class TestNonarrayArgs(TestCase):
|
|||
# pytest.param(
|
||||
# 2**31 - 1, -1, marks=pytest.mark.xfail(reason="Out of range of int32")
|
||||
# ),
|
||||
subtest((2**31 - 1, -1), decorators=[xpassIfTorchDynamo]),
|
||||
subtest((2**31 - 1, -1), decorators=[xpassIfTorchDynamo_np]),
|
||||
subtest(
|
||||
(2**31 - 1, 1 - math.ceil(math.log10(2**31 - 1))),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
(2**31 - 1, -math.ceil(math.log10(2**31 - 1))),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
@ -611,7 +611,7 @@ class TestBoolCmp(TestCase):
|
|||
assert_array_equal(np.signbit(self.signd[i:]), self.ed[i:])
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestSeterr(TestCase):
|
||||
def test_default(self):
|
||||
err = np.geterr()
|
||||
|
|
@ -870,7 +870,7 @@ class TestTypes(TestCase):
|
|||
# assert_equal(b, [0.0, 1.5])
|
||||
# assert_equal(b.dtype, np.dtype('f4'))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="'Scalars do not upcast arrays' rule")
|
||||
@xpassIfTorchDynamo_np # (reason="'Scalars do not upcast arrays' rule")
|
||||
def test_coercion_2(self):
|
||||
def res_type(a, b):
|
||||
return np.add(a, b).dtype
|
||||
|
|
@ -921,7 +921,7 @@ class TestTypes(TestCase):
|
|||
# Also test keyword arguments
|
||||
assert_(np.can_cast(from_=np.int32, to=np.int64))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="value-based casting?")
|
||||
@xpassIfTorchDynamo_np # (reason="value-based casting?")
|
||||
def test_can_cast_values(self):
|
||||
# gh-5917
|
||||
for dt in [np.int8, np.int16, np.int32, np.int64] + [
|
||||
|
|
@ -948,7 +948,7 @@ class NIterError(Exception):
|
|||
|
||||
|
||||
@skip(reason="NP_VER: fails on CI")
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
@instantiate_parametrized_tests
|
||||
class TestFromiter(TestCase):
|
||||
def makegen(self):
|
||||
|
|
@ -1174,7 +1174,7 @@ class TestIndex(TestCase):
|
|||
assert_equal(c.dtype, np.dtype("int32"))
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestBinaryRepr(TestCase):
|
||||
def test_zero(self):
|
||||
assert_equal(np.binary_repr(0), "0")
|
||||
|
|
@ -1212,7 +1212,7 @@ class TestBinaryRepr(TestCase):
|
|||
assert_equal(np.binary_repr(np.int64(-(2**62)), width=64), "11" + "0" * 62)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestBaseRepr(TestCase):
|
||||
def test_base3(self):
|
||||
assert_equal(np.base_repr(3**5, 3), "100000")
|
||||
|
|
@ -1425,7 +1425,7 @@ class TestClip(TestCase):
|
|||
act = self.clip(a, m, M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="byteorder not supported in torch")
|
||||
@xpassIfTorchDynamo_np # (reason="byteorder not supported in torch")
|
||||
def test_simple_nonnative(self):
|
||||
# Test non native double input with scalar min/max.
|
||||
# Test native double input with non native double scalar min/max.
|
||||
|
|
@ -1445,7 +1445,7 @@ class TestClip(TestCase):
|
|||
act = self.clip(a, m, M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="clamp not supported for complex")
|
||||
@xpassIfTorchDynamo_np # (reason="clamp not supported for complex")
|
||||
def test_simple_complex(self):
|
||||
# Test native complex input with native double scalar min/max.
|
||||
# Test native input with complex double scalar min/max.
|
||||
|
|
@ -1498,12 +1498,12 @@ class TestClip(TestCase):
|
|||
self.clip(a, m, M, act)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
# @xpassIfTorchDynamo # (reason="casting not supported")
|
||||
# @xpassIfTorchDynamo_np # (reason="casting not supported")
|
||||
@parametrize(
|
||||
"casting",
|
||||
[
|
||||
subtest(None, decorators=[xfail]),
|
||||
subtest("unsafe", decorators=[xpassIfTorchDynamo]),
|
||||
subtest("unsafe", decorators=[xpassIfTorchDynamo_np]),
|
||||
],
|
||||
)
|
||||
def test_simple_int32_inout(self, casting):
|
||||
|
|
@ -1631,7 +1631,7 @@ class TestClip(TestCase):
|
|||
act = self.clip(a, m * np.zeros(a.shape), M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="newbyteorder not supported")
|
||||
@xpassIfTorchDynamo_np # (reason="newbyteorder not supported")
|
||||
def test_type_cast_06(self):
|
||||
# Test native with NON native scalar min/max.
|
||||
a = self._generate_data(self.nr, self.nc)
|
||||
|
|
@ -1642,7 +1642,7 @@ class TestClip(TestCase):
|
|||
ac = self.fastclip(a, m_s, M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="newbyteorder not supported")
|
||||
@xpassIfTorchDynamo_np # (reason="newbyteorder not supported")
|
||||
def test_type_cast_07(self):
|
||||
# Test NON native with native array min/max.
|
||||
a = self._generate_data(self.nr, self.nc)
|
||||
|
|
@ -1654,7 +1654,7 @@ class TestClip(TestCase):
|
|||
ac = self.fastclip(a_s, m, M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="newbyteorder not supported")
|
||||
@xpassIfTorchDynamo_np # (reason="newbyteorder not supported")
|
||||
def test_type_cast_08(self):
|
||||
# Test NON native with native scalar min/max.
|
||||
a = self._generate_data(self.nr, self.nc)
|
||||
|
|
@ -1666,7 +1666,7 @@ class TestClip(TestCase):
|
|||
act = a_s.clip(m, M)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="newbyteorder not supported")
|
||||
@xpassIfTorchDynamo_np # (reason="newbyteorder not supported")
|
||||
def test_type_cast_09(self):
|
||||
# Test native with NON native array min/max.
|
||||
a = self._generate_data(self.nr, self.nc)
|
||||
|
|
@ -1688,7 +1688,7 @@ class TestClip(TestCase):
|
|||
ac = self.fastclip(a, m, M, out=b)
|
||||
assert_array_equal(ac, act)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="newbyteorder not supported")
|
||||
@xpassIfTorchDynamo_np # (reason="newbyteorder not supported")
|
||||
def test_type_cast_11(self):
|
||||
# Test non native with native scalar, min/max, out non native
|
||||
a = self._generate_non_native_data(self.nr, self.nc)
|
||||
|
|
@ -2538,7 +2538,7 @@ class TestArgwhere(TestCase):
|
|||
assert_equal(np.argwhere([4, 0, 2, 1, 3]), [[0], [2], [3], [4]])
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestStringFunction(TestCase):
|
||||
def test_set_string_function(self):
|
||||
a = np.array([1])
|
||||
|
|
@ -2902,7 +2902,7 @@ class TestIndices(TestCase):
|
|||
assert_(arr.dtype == dtype)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestRequire(TestCase):
|
||||
flag_names = [
|
||||
"C",
|
||||
|
|
@ -2969,7 +2969,7 @@ class TestRequire(TestCase):
|
|||
assert_raises(ValueError, np.require, a, None, ["C", "F"])
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
class TestBroadcast(TestCase):
|
||||
def test_broadcast_in_args(self):
|
||||
# gh-5881
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from torch.testing._internal.common_utils import (
|
|||
skipIfTorchDynamo,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ else:
|
|||
skip = functools.partial(skipif, True)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (
|
||||
@xpassIfTorchDynamo_np # (
|
||||
# reason="We do not disctinguish between scalar and array types."
|
||||
# " Thus, scalars can upcast arrays."
|
||||
# )
|
||||
|
|
@ -111,7 +111,7 @@ class TestIsSubDType(TestCase):
|
|||
assert np.issubdtype(np.float32, "f")
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (
|
||||
@xpassIfTorchDynamo_np # (
|
||||
# reason="We do not have (or need) np.core.numerictypes."
|
||||
# " Our type aliases are in _dtypes.py."
|
||||
# )
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ skip = functools.partial(skipif, True)
|
|||
|
||||
|
||||
class TestFromString(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="XXX: floats from strings")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: floats from strings")
|
||||
def test_floating(self):
|
||||
# Ticket #640, floats from string
|
||||
fsingle = np.single("1.234")
|
||||
|
|
@ -39,7 +39,7 @@ class TestFromString(TestCase):
|
|||
assert_almost_equal(fsingle, 1.234)
|
||||
assert_almost_equal(fdouble, 1.234)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: floats from strings")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: floats from strings")
|
||||
def test_floating_overflow(self):
|
||||
"""Strings containing an unrepresentable float overflow"""
|
||||
fhalf = np.half("1e10000")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ class TestBaseMath(TestCase):
|
|||
np.add(2, inp2, out=out)
|
||||
assert_almost_equal(out, exp1 + 2, err_msg=msg)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not have .view")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not have .view")
|
||||
def test_lower_align(self):
|
||||
# check data that is not aligned to element size
|
||||
# i.e doubles are aligned to 4 bytes on i386
|
||||
|
|
@ -196,7 +196,7 @@ class TestPower(TestCase):
|
|||
assert_almost_equal(b, 6765201, err_msg=msg)
|
||||
|
||||
@skip(reason="NP_VER: fails on CI on older NumPy")
|
||||
@xpassIfTorchDynamo # (reason="Value-based casting: (2)**(-2) -> 0 in pytorch.")
|
||||
@xpassIfTorchDynamo_np # (reason="Value-based casting: (2)**(-2) -> 0 in pytorch.")
|
||||
def test_integers_to_negative_integer_power(self):
|
||||
# Note that the combination of uint64 with a signed integer
|
||||
# has common type np.float64. The other combinations should all
|
||||
|
|
@ -464,7 +464,7 @@ class TestConversion(TestCase):
|
|||
assert_equal([int(_m) for _m in a], li)
|
||||
|
||||
@skipif(numpy.__version__ < "1.24", reason="NP_VER: fails on NumPy 1.23.x")
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not emit this warning.")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not emit this warning.")
|
||||
def test_iinfo_long_values_1(self):
|
||||
for code in "bBh":
|
||||
with pytest.warns(DeprecationWarning):
|
||||
|
|
@ -567,7 +567,7 @@ class TestConversion(TestCase):
|
|||
# assert_equal( val, val2 )
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="can delegate repr to pytorch")
|
||||
@xpassIfTorchDynamo_np # (reason="can delegate repr to pytorch")
|
||||
class TestRepr(TestCase):
|
||||
def _test_type_repr(self, t):
|
||||
finfo = np.finfo(t)
|
||||
|
|
@ -846,7 +846,7 @@ class TestScalarOpsMisc(TestCase):
|
|||
operation(min, neg_1)
|
||||
|
||||
@skipif(numpy.__version__ < "1.24", reason="NP_VER: fails on NumPy 1.23.x")
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not warn on overflow")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not warn on overflow")
|
||||
@parametrize("dtype", "B")
|
||||
def test_scalar_unsigned_integer_overflow(self, dtype):
|
||||
val = np.dtype(dtype).type(8)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -358,7 +358,7 @@ class TestConcatenate(TestCase):
|
|||
assert out is rout
|
||||
assert np.all(r == rout)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="concatenate(x, axis=None) relies on x being a sequence")
|
||||
@xpassIfTorchDynamo_np # (reason="concatenate(x, axis=None) relies on x being a sequence")
|
||||
def test_large_concatenate_axis_None(self):
|
||||
# When no axis is given, concatenate uses flattened versions.
|
||||
# This also had a bug with many arrays (see gh-5979).
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ else:
|
|||
|
||||
|
||||
class TestConstant(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="tuple values")
|
||||
@xpassIfTorchDynamo_np # (reason="tuple values")
|
||||
def test_check_constant(self):
|
||||
a = np.arange(100)
|
||||
a = np.pad(a, (25, 20), "constant", constant_values=(10, 20))
|
||||
|
|
@ -369,7 +369,7 @@ class TestConstant(TestCase):
|
|||
)
|
||||
assert_allclose(test, expected)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="tuple values")
|
||||
@xpassIfTorchDynamo_np # (reason="tuple values")
|
||||
def test_check_constant_float3(self):
|
||||
a = np.arange(100, dtype=float)
|
||||
a = np.pad(a, (25, 20), "constant", constant_values=(-1.1, -1.2))
|
||||
|
|
@ -540,7 +540,7 @@ class TestConstant(TestCase):
|
|||
)
|
||||
assert_allclose(test, expected)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="tuple values")
|
||||
@xpassIfTorchDynamo_np # (reason="tuple values")
|
||||
def test_check_constant_pad_2d(self):
|
||||
arr = np.arange(4).reshape(2, 2)
|
||||
test = np.pad(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -761,7 +761,7 @@ class TestUnique(TestCase):
|
|||
# assert_equal(a3_idx.dtype, np.intp)
|
||||
# assert_equal(a3_inv.dtype, np.intp)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="unique with nans")
|
||||
@xpassIfTorchDynamo_np # (reason="unique with nans")
|
||||
def test_unique_1d_2(self):
|
||||
# test for ticket 2111 - float
|
||||
a = [2.0, np.nan, 1.0, np.nan]
|
||||
|
|
@ -807,7 +807,7 @@ class TestUnique(TestCase):
|
|||
assert_array_equal(unique(inp, axis=0), unique(inp_arr, axis=0), msg)
|
||||
assert_array_equal(unique(inp, axis=1), unique(inp_arr, axis=1), msg)
|
||||
|
||||
@xpassIfTorchDynamo # _run_axis_tests xfails with the message
|
||||
@xpassIfTorchDynamo_np # _run_axis_tests xfails with the message
|
||||
# torch has different unique ordering behaviour"
|
||||
def test_unique_axis(self):
|
||||
types = []
|
||||
|
|
@ -833,7 +833,7 @@ class TestUnique(TestCase):
|
|||
uniq = unique(x, axis=axis)
|
||||
assert_array_equal(uniq, [1, 2, 3, 4])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="unique / return_index")
|
||||
@xpassIfTorchDynamo_np # (reason="unique / return_index")
|
||||
def test_unique_axis_zeros(self):
|
||||
# issue 15559
|
||||
single_zero = np.empty(shape=(2, 0), dtype=np.int8)
|
||||
|
|
@ -941,7 +941,7 @@ class TestUnique(TestCase):
|
|||
assert_array_equal(cnt, np.array([2, 1, 1]), msg)
|
||||
|
||||
@skipIf(True, reason="NP_VER: fails on CI with older NumPy")
|
||||
@xpassIfTorchDynamo # (reason="unique / return_index / nans")
|
||||
@xpassIfTorchDynamo_np # (reason="unique / return_index / nans")
|
||||
def test_unique_nanequals(self):
|
||||
# issue 20326
|
||||
a = np.array([1, 1, np.nan, np.nan, np.nan])
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -35,10 +35,22 @@ IS_PYPY = False
|
|||
|
||||
import string
|
||||
|
||||
|
||||
# FIXME: make from torch._numpy
|
||||
# These are commented, as if they are imported, some of the tests pass for the wrong reasons
|
||||
# from numpy lib import digitize, piecewise, trapz, select, trim_zeros, interp
|
||||
from numpy.lib import delete, extract, insert, msort, place, setxor1d, unwrap, vectorize
|
||||
# FIXME: broken on numpy 2.0+
|
||||
if int(numpy.__version__[0]) < 2:
|
||||
from numpy.lib import (
|
||||
delete,
|
||||
extract,
|
||||
insert,
|
||||
msort,
|
||||
place,
|
||||
setxor1d,
|
||||
unwrap,
|
||||
vectorize,
|
||||
)
|
||||
|
||||
|
||||
# If we are going to trace through these, we should use NumPy
|
||||
|
|
@ -296,7 +308,7 @@ class TestCopy(TestCase):
|
|||
assert_equal(a[0, 0], 1)
|
||||
assert_equal(a_copy[0, 0], 10)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="order='F' not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="order='F' not implemented")
|
||||
def test_order(self):
|
||||
# It turns out that people rely on np.copy() preserving order by
|
||||
# default; changing this broke scikit-learn:
|
||||
|
|
@ -524,7 +536,7 @@ class TestSelect(TestCase):
|
|||
select(conditions, choices)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
@instantiate_parametrized_tests
|
||||
class TestInsert(TestCase):
|
||||
def test_basic(self):
|
||||
|
|
@ -843,7 +855,7 @@ class TestDiff(TestCase):
|
|||
assert_raises(np.AxisError, diff, x, append=0, axis=3)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
@instantiate_parametrized_tests
|
||||
class TestDelete(TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -1192,7 +1204,7 @@ class TestAngle(TestCase):
|
|||
assert_array_almost_equal(z, zo, 11)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo
|
||||
@xpassIfTorchDynamo_np
|
||||
@instantiate_parametrized_tests
|
||||
class TestTrimZeros(TestCase):
|
||||
a = np.array([0, 0, 1, 0, 2, 3, 4, 0])
|
||||
|
|
@ -1264,7 +1276,7 @@ class TestTrimZeros(TestCase):
|
|||
assert isinstance(res, list)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
class TestExtins(TestCase):
|
||||
def test_basic(self):
|
||||
a = np.array([1, 3, 2, 1, 2, 3, 3])
|
||||
|
|
@ -1666,7 +1678,7 @@ class TestVectorize(TestCase):
|
|||
f(x)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
class TestDigitize(TestCase):
|
||||
def test_forward(self):
|
||||
x = np.arange(-6, 5)
|
||||
|
|
@ -1881,7 +1893,7 @@ class TestFilterwindows(TestCase):
|
|||
assert_almost_equal(np.sum(w, axis=0), 10, 15)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
class TestTrapz(TestCase):
|
||||
def test_simple(self):
|
||||
x = np.arange(-10, 10, 0.1)
|
||||
|
|
@ -1950,13 +1962,13 @@ class TestUnique(TestCase):
|
|||
|
||||
assert_(unique(np.array([1, 1, 1, 1, 1])) == np.array([1]))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="unique not implemented for 'ComplexDouble'")
|
||||
@xpassIfTorchDynamo_np # (reason="unique not implemented for 'ComplexDouble'")
|
||||
def test_simple_complex(self):
|
||||
x = np.array([5 + 6j, 1 + 1j, 1 + 10j, 10, 5 + 6j])
|
||||
assert_(np.all(unique(x) == [1 + 1j, 1 + 10j, 5 + 6j, 10]))
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
class TestCheckFinite(TestCase):
|
||||
def test_simple(self):
|
||||
a = [1, 2, 3]
|
||||
|
|
@ -2613,7 +2625,7 @@ parametrize_interp_sc = parametrize(
|
|||
)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
@instantiate_parametrized_tests
|
||||
class TestInterp(TestCase):
|
||||
def test_exceptions(self):
|
||||
|
|
@ -2857,7 +2869,7 @@ class TestPercentile(TestCase):
|
|||
assert_array_equal(np.percentile(x, 50, axis=0), [1, 1, 1])
|
||||
|
||||
@skip(reason="NP_VER: fails on CI; no method=")
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
@parametrize("dtype", np.typecodes["Float"])
|
||||
def test_linear_nan_1D(self, dtype):
|
||||
# METHOD 1 of H&F
|
||||
|
|
@ -3160,7 +3172,7 @@ class TestPercentile(TestCase):
|
|||
b = np.percentile([2, 3, 4, 1], [50], overwrite_input=True)
|
||||
assert_equal(b, np.array([2.5]))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch percentile does not support tuple axes.")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch percentile does not support tuple axes.")
|
||||
def test_extended_axis(self):
|
||||
o = np.random.normal(size=(71, 23))
|
||||
x = np.dstack([o] * 10)
|
||||
|
|
@ -3330,7 +3342,7 @@ class TestPercentile(TestCase):
|
|||
assert_equal(np.percentile(d, 1, method="nearest", out=o), o)
|
||||
|
||||
@skip(reason="NP_VER: fails on CI; no method=")
|
||||
@xpassIfTorchDynamo # (reason="np.percentile undocumented nan weirdness")
|
||||
@xpassIfTorchDynamo_np # (reason="np.percentile undocumented nan weirdness")
|
||||
def test_nan_behavior(self):
|
||||
a = np.arange(24, dtype=float)
|
||||
a[2] = np.nan
|
||||
|
|
@ -3496,50 +3508,50 @@ class TestQuantile(TestCase):
|
|||
subtest(
|
||||
"inverted_cdf",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"averaged_inverted_cdf",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"closest_observation",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"interpolated_inverted_cdf",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"hazen",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"weibull",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
"linear",
|
||||
subtest(
|
||||
"median_unbiased",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
subtest(
|
||||
"normal_unbiased",
|
||||
decorators=[
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
],
|
||||
),
|
||||
"nearest",
|
||||
|
|
@ -3716,7 +3728,7 @@ class TestMedian(TestCase):
|
|||
b[1, 2] = np.nan
|
||||
assert_equal(np.median(a, 1), b)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="median: does not support tuple axes")
|
||||
@xpassIfTorchDynamo_np # (reason="median: does not support tuple axes")
|
||||
def test_nan_behavior_2(self):
|
||||
a = np.arange(24, dtype=float).reshape(2, 3, 4)
|
||||
a[1, 2, 3] = np.nan
|
||||
|
|
@ -3737,7 +3749,7 @@ class TestMedian(TestCase):
|
|||
# no axis
|
||||
assert_equal(np.median(a).ndim, 0)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="median: torch.quantile does not handle empty tensors")
|
||||
@xpassIfTorchDynamo_np # (reason="median: torch.quantile does not handle empty tensors")
|
||||
@skipif(IS_WASM, reason="fp errors don't work correctly")
|
||||
def test_empty(self):
|
||||
# mean(empty array) emits two warnings: empty slice and divide by 0
|
||||
|
|
@ -3768,7 +3780,7 @@ class TestMedian(TestCase):
|
|||
assert_equal(np.median(a, axis=2), b)
|
||||
assert_(w[0].category is RuntimeWarning)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="median: tuple axes not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="median: tuple axes not implemented")
|
||||
def test_extended_axis(self):
|
||||
o = np.random.normal(size=(71, 23))
|
||||
x = np.dstack([o] * 10)
|
||||
|
|
@ -3818,7 +3830,7 @@ class TestMedian(TestCase):
|
|||
d = np.ones((3, 5, 7, 11))
|
||||
assert_equal(np.median(d, axis=None, keepdims=True).shape, (1, 1, 1, 1))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="median: tuple axis")
|
||||
@xpassIfTorchDynamo_np # (reason="median: tuple axis")
|
||||
def test_keepdims_2(self):
|
||||
d = np.ones((3, 5, 7, 11))
|
||||
assert_equal(np.median(d, axis=(0, 1), keepdims=True).shape, (1, 1, 7, 11))
|
||||
|
|
@ -3863,7 +3875,7 @@ class TestMedian(TestCase):
|
|||
assert_equal(result.shape, shape_out)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement")
|
||||
@instantiate_parametrized_tests
|
||||
class TestSortComplex(TestCase):
|
||||
@parametrize(
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from torch.testing._internal.common_utils import (
|
|||
slowTest as slow,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ class TestHistogram(TestCase):
|
|||
)
|
||||
assert_almost_equal(a, [0.2, 0.1, 0.1, 0.075])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="histogram complex weights")
|
||||
@xpassIfTorchDynamo_np # (reason="histogram complex weights")
|
||||
def test_exotic_weights(self):
|
||||
# Test the use of weights that are not integer or floats, but e.g.
|
||||
# complex numbers or object types.
|
||||
|
|
@ -287,7 +287,7 @@ class TestHistogram(TestCase):
|
|||
with assert_raises((RuntimeError, ValueError)):
|
||||
np.histogram(vals, bins=bins)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="no uint64")
|
||||
@xpassIfTorchDynamo_np # (reason="no uint64")
|
||||
def test_unsigned_monotonicity_check(self):
|
||||
# Ensures ValueError is raised if bins not increasing monotonically
|
||||
# when bins contain unsigned values (see #9222)
|
||||
|
|
@ -313,7 +313,7 @@ class TestHistogram(TestCase):
|
|||
np.histogram([np.array(0.5) for i in range(10)] + [0.500000000000001])
|
||||
np.histogram([np.array(0.5) for i in range(10)] + [0.5])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="bins='auto'")
|
||||
@xpassIfTorchDynamo_np # (reason="bins='auto'")
|
||||
def test_some_nan_values(self):
|
||||
# gh-7503
|
||||
one_nan = np.array([0, 1, np.nan])
|
||||
|
|
@ -394,14 +394,14 @@ class TestHistogram(TestCase):
|
|||
self.do_precision_lower_bound(float_small, float_large)
|
||||
self.do_precision_upper_bound(float_small, float_large)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="mixed dtypes")
|
||||
@xpassIfTorchDynamo_np # (reason="mixed dtypes")
|
||||
def test_precision(self):
|
||||
# not looping results in a useful stack trace upon failure
|
||||
self.do_precision(np.half, np.single)
|
||||
self.do_precision(np.half, np.double)
|
||||
self.do_precision(np.single, np.double)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="histogram_bin_edges")
|
||||
@xpassIfTorchDynamo_np # (reason="histogram_bin_edges")
|
||||
def test_histogram_bin_edges(self):
|
||||
hist, e = histogram([1, 2, 3, 4], [1, 2])
|
||||
edges = histogram_bin_edges([1, 2, 3, 4], [1, 2])
|
||||
|
|
@ -417,7 +417,7 @@ class TestHistogram(TestCase):
|
|||
assert_allclose(edges, e, atol=2e-15)
|
||||
|
||||
# @requires_memory(free_bytes=1e10)
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not support bins = [int, int, array]")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not support bins = [int, int, array]")
|
||||
@slow
|
||||
def test_big_arrays(self):
|
||||
sample = np.zeros([100000000, 3])
|
||||
|
|
@ -428,7 +428,7 @@ class TestHistogram(TestCase):
|
|||
assert_equal(type(hist), type((1, 2)))
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
@instantiate_parametrized_tests
|
||||
class TestHistogramOptimBinNums(TestCase):
|
||||
"""
|
||||
|
|
@ -854,13 +854,13 @@ class TestHistogramdd(TestCase):
|
|||
(RuntimeError, ValueError), np.histogramdd, x, bins=[1, 1, 1, [1, 2, 3, -3]]
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not support bins = [int, int, array]")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not support bins = [int, int, array]")
|
||||
def test_bins_error_2(self):
|
||||
# mixing scalar (# of bins) and explicit bin arrays, ugh
|
||||
x = np.arange(8).reshape(2, 4)
|
||||
assert_(np.histogramdd(x, bins=[1, 1, 1, [1, 2, 3, 4]]))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not support bins = [int, int, array]")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not support bins = [int, int, array]")
|
||||
def test_inf_edges(self):
|
||||
# Test using +/-inf bin edges works. See #1788.
|
||||
x = np.arange(6).reshape(3, 2)
|
||||
|
|
@ -911,7 +911,7 @@ class TestHistogramdd(TestCase):
|
|||
range=[[0.0, 1.0], [np.nan, 0.75], [0.25, 0.5]],
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not allow equal entries")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not allow equal entries")
|
||||
def test_equal_edges(self):
|
||||
"""Test that adjacent entries in an edge array can be equal"""
|
||||
x = np.array([0, 1, 2])
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ else:
|
|||
)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="unravel_index not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="unravel_index not implemented")
|
||||
@instantiate_parametrized_tests
|
||||
class TestRavelUnravelIndex(TestCase):
|
||||
def test_basic(self):
|
||||
|
|
@ -451,7 +451,7 @@ class TestIx_(TestCase):
|
|||
|
||||
|
||||
class TestC(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="c_ not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="c_ not implemented")
|
||||
def test_c_(self):
|
||||
a = np.c_[np.array([[1, 2, 3]]), 0, 0, np.array([[4, 5, 6]])]
|
||||
assert_equal(a, [[1, 2, 3, 0, 0, 4, 5, 6]])
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from torch.testing._internal.common_utils import (
|
|||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xfailIfTorchDynamo,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ class TestPutAlongAxis(TestCase):
|
|||
|
||||
assert_equal(i_min, i_max)
|
||||
|
||||
@xpassIfTorchDynamo # (
|
||||
@xpassIfTorchDynamo_np # (
|
||||
# reason="RuntimeError: Expected index [1, 2, 5] to be smaller than self [3, 4, 1] apart from dimension 1")
|
||||
def test_broadcast(self):
|
||||
"""Test that non-indexing dimensions are broadcast in both directions"""
|
||||
|
|
@ -162,7 +162,7 @@ class TestPutAlongAxis(TestCase):
|
|||
assert_equal(take_along_axis(a, ai, axis=1), 20)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="apply_along_axis not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="apply_along_axis not implemented")
|
||||
class TestApplyAlongAxis(TestCase):
|
||||
def test_simple(self):
|
||||
a = np.ones((20, 10), "d")
|
||||
|
|
@ -741,7 +741,7 @@ class TestSqueeze(TestCase):
|
|||
assert_(a.flags.f_contiguous)
|
||||
assert_(b.flags.f_contiguous)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: noop in torch, while numpy raises")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: noop in torch, while numpy raises")
|
||||
def test_squeeze_axis_handling(self):
|
||||
with assert_raises(ValueError):
|
||||
np.squeeze(np.array([[1], [2], [3]]), axis=0)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class TestEye(TestCase):
|
|||
def test_bool(self):
|
||||
assert_equal(eye(2, 2, dtype=bool), [[True, False], [False, True]])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: implement order=non-default")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: implement order=non-default")
|
||||
def test_order(self):
|
||||
mat_c = eye(4, 3, k=-1)
|
||||
mat_f = eye(4, 3, k=-1, order="F")
|
||||
|
|
@ -174,7 +174,7 @@ class TestDiag(TestCase):
|
|||
b[k] = vals[k + 2, k]
|
||||
assert_equal(diag(vals, -2), b[:3])
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO implement orders")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO implement orders")
|
||||
def test_fortran_order(self):
|
||||
vals = array((100 * get_mat(5) + 1), order="F", dtype="l")
|
||||
self.check_matrix(vals)
|
||||
|
|
@ -283,7 +283,7 @@ class TestHistogram2d(TestCase):
|
|||
# assert_array_max_ulp(a, np.zeros((4, 4)))
|
||||
assert_allclose(a, np.zeros((4, 4)), atol=1e-15)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="pytorch does not support bins = [int, array]")
|
||||
@xpassIfTorchDynamo_np # (reason="pytorch does not support bins = [int, array]")
|
||||
def test_binparameter_combination(self):
|
||||
x = array([0, 0.09207008, 0.64575234, 0.12875982, 0.47390599, 0.59944483, 1])
|
||||
y = array([0, 0.14344267, 0.48988575, 0.30558665, 0.44700682, 0.15886423, 1])
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ def assert_all(x):
|
|||
assert_(np.all(x), x)
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="common_type not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="common_type not implemented")
|
||||
class TestCommonType(TestCase):
|
||||
def test_basic(self):
|
||||
ai32 = np.array([[1, 2], [3, 4]], dtype=np.int32)
|
||||
|
|
@ -118,7 +118,7 @@ class TestMintypecode(TestCase):
|
|||
assert_equal(mintypecode("idD"), "D")
|
||||
|
||||
|
||||
@xpassIfTorchDynamo # (reason="TODO: decide on if [1] is a scalar or not")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO: decide on if [1] is a scalar or not")
|
||||
class TestIsscalar(TestCase):
|
||||
def test_basic(self):
|
||||
assert_(np.isscalar(3))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from torch.testing._internal.common_utils import (
|
|||
slowTest as slow,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1013,7 +1013,7 @@ class LstsqCases(LinalgSquareTestCase, LinalgNonsquareTestCase):
|
|||
|
||||
@instantiate_parametrized_tests
|
||||
class TestLstsq(LstsqCases, TestCase):
|
||||
@xpassIfTorchDynamo # (reason="Lstsq: we use the future default =None")
|
||||
@xpassIfTorchDynamo_np # (reason="Lstsq: we use the future default =None")
|
||||
def test_future_rcond(self):
|
||||
a = np.array(
|
||||
[
|
||||
|
|
@ -1758,7 +1758,7 @@ class TestQR(TestCase):
|
|||
assert_(isinstance(r2, a_type))
|
||||
assert_almost_equal(r2, r1)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="torch does not allow qr(..., mode='raw'")
|
||||
@xpassIfTorchDynamo_np # (reason="torch does not allow qr(..., mode='raw'")
|
||||
@parametrize("m, n", [(3, 0), (0, 3), (0, 0)])
|
||||
def test_qr_empty(self, m, n):
|
||||
k = min(m, n)
|
||||
|
|
@ -1772,7 +1772,7 @@ class TestQR(TestCase):
|
|||
assert_equal(h.shape, (n, m))
|
||||
assert_equal(tau.shape, (k,))
|
||||
|
||||
@xpassIfTorchDynamo # (reason="torch does not allow qr(..., mode='raw'")
|
||||
@xpassIfTorchDynamo_np # (reason="torch does not allow qr(..., mode='raw'")
|
||||
def test_mode_raw(self):
|
||||
# The factorization is not unique and varies between libraries,
|
||||
# so it is not possible to check against known values. Functional
|
||||
|
|
@ -1908,7 +1908,7 @@ class TestCholesky(TestCase):
|
|||
|
||||
|
||||
class TestMisc(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="endianness")
|
||||
@xpassIfTorchDynamo_np # (reason="endianness")
|
||||
def test_byteorder_check(self):
|
||||
# Byte order check should pass for native order
|
||||
if sys.byteorder == "little":
|
||||
|
|
@ -2244,7 +2244,7 @@ class TestTensorsolve(TestCase):
|
|||
|
||||
|
||||
class TestMisc2(TestCase):
|
||||
@xpassIfTorchDynamo # (reason="TODO")
|
||||
@xpassIfTorchDynamo_np # (reason="TODO")
|
||||
def test_unsupported_commontype(self):
|
||||
# linalg gracefully handles unsupported type
|
||||
arr = np.array([[1, -2], [2, 5]], dtype="float16")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from torch.testing._internal.common_utils import (
|
|||
subtest,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -411,37 +411,48 @@ class TestArgmax(TestCase):
|
|||
)
|
||||
]
|
||||
nan_arr = darr + [
|
||||
subtest(([0, 1, 2, 3, complex(0, np.nan)], 4), decorators=[xpassIfTorchDynamo]),
|
||||
subtest(([0, 1, 2, 3, complex(np.nan, 0)], 4), decorators=[xpassIfTorchDynamo]),
|
||||
subtest(([0, 1, 2, complex(np.nan, 0), 3], 3), decorators=[xpassIfTorchDynamo]),
|
||||
subtest(([0, 1, 2, complex(0, np.nan), 3], 3), decorators=[xpassIfTorchDynamo]),
|
||||
subtest(([complex(0, np.nan), 0, 1, 2, 3], 0), decorators=[xpassIfTorchDynamo]),
|
||||
subtest(
|
||||
([complex(np.nan, np.nan), 0, 1, 2, 3], 0), decorators=[xpassIfTorchDynamo]
|
||||
([0, 1, 2, 3, complex(0, np.nan)], 4), decorators=[xpassIfTorchDynamo_np]
|
||||
),
|
||||
subtest(
|
||||
([0, 1, 2, 3, complex(np.nan, 0)], 4), decorators=[xpassIfTorchDynamo_np]
|
||||
),
|
||||
subtest(
|
||||
([0, 1, 2, complex(np.nan, 0), 3], 3), decorators=[xpassIfTorchDynamo_np]
|
||||
),
|
||||
subtest(
|
||||
([0, 1, 2, complex(0, np.nan), 3], 3), decorators=[xpassIfTorchDynamo_np]
|
||||
),
|
||||
subtest(
|
||||
([complex(0, np.nan), 0, 1, 2, 3], 0), decorators=[xpassIfTorchDynamo_np]
|
||||
),
|
||||
subtest(
|
||||
([complex(np.nan, np.nan), 0, 1, 2, 3], 0),
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(np.nan, 0), complex(np.nan, 2), complex(np.nan, 1)], 0),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(np.nan, np.nan), complex(np.nan, 2), complex(np.nan, 1)], 0),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(np.nan, 0), complex(np.nan, 2), complex(np.nan, np.nan)], 0),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(0, 0), complex(0, 2), complex(0, 1)], 1),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(1, 0), complex(0, 2), complex(0, 1)], 0),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
subtest(
|
||||
([complex(1, 0), complex(0, 2), complex(1, 1)], 2),
|
||||
decorators=[xpassIfTorchDynamo],
|
||||
decorators=[xpassIfTorchDynamo_np],
|
||||
),
|
||||
([False, False, False, False, True], 4),
|
||||
([False, False, False, True, False], 3),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from torch.testing._internal.common_utils import (
|
|||
run_tests,
|
||||
TEST_WITH_TORCHDYNAMO,
|
||||
TestCase,
|
||||
xpassIfTorchDynamo,
|
||||
xpassIfTorchDynamo_np,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ class TestMean(TestCase):
|
|||
# of float32.
|
||||
assert np.mean(np.ones(100000, dtype="float16")) == 1
|
||||
|
||||
@xpassIfTorchDynamo # (reason="XXX: mean(..., where=...) not implemented")
|
||||
@xpassIfTorchDynamo_np # (reason="XXX: mean(..., where=...) not implemented")
|
||||
def test_mean_where(self):
|
||||
a = np.arange(16).reshape((4, 4))
|
||||
wh_full = np.array(
|
||||
|
|
@ -194,7 +194,7 @@ class TestSum(TestCase):
|
|||
assert res_float.dtype == "float64"
|
||||
|
||||
@skipIf(numpy.__version__ < "1.24", reason="NP_VER: fails on NumPy 1.23.x")
|
||||
@xpassIfTorchDynamo # (reason="sum: does not warn on overflow")
|
||||
@xpassIfTorchDynamo_np # (reason="sum: does not warn on overflow")
|
||||
def test_sum_dtypes_warnings(self):
|
||||
for dt in (int, np.float16, np.float32, np.float64):
|
||||
for v in (0, 1, 2, 7, 8, 9, 15, 16, 19, 127, 128, 1024, 1235):
|
||||
|
|
@ -261,7 +261,7 @@ class TestSum(TestCase):
|
|||
d += d
|
||||
assert_allclose(d, 2.0 + 2j, atol=1.5e-7)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="initial=... need implementing")
|
||||
@xpassIfTorchDynamo_np # (reason="initial=... need implementing")
|
||||
def test_sum_initial(self):
|
||||
# Integer, single axis
|
||||
assert_equal(np.sum([3], initial=2), 5)
|
||||
|
|
@ -275,7 +275,7 @@ class TestSum(TestCase):
|
|||
[12, 12, 12],
|
||||
)
|
||||
|
||||
@xpassIfTorchDynamo # (reason="where=... need implementing")
|
||||
@xpassIfTorchDynamo_np # (reason="where=... need implementing")
|
||||
def test_sum_where(self):
|
||||
# More extensive tests done in test_reduction_with_where.
|
||||
assert_equal(np.sum([[1.0, 2.0], [3.0, 4.0]], where=[True, False]), 4.0)
|
||||
|
|
|
|||
|
|
@ -1581,7 +1581,11 @@ if TEST_WITH_TORCHDYNAMO:
|
|||
torch._inductor.config.fallback_random = True
|
||||
|
||||
|
||||
def xpassIfTorchDynamo(func):
|
||||
# seems like this is only used in test/torch_np
|
||||
def xpassIfTorchDynamo_np(func):
|
||||
# numpy 2.0+ is causing issues
|
||||
if TEST_WITH_TORCHDYNAMO and np.__version__[0] == '2':
|
||||
return unittest.skip("skipping numpy 2.0+ dynamo-wrapped test")(func)
|
||||
return func if TEST_WITH_TORCHDYNAMO else unittest.expectedFailure(func)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user