@pytest.mark.parametrize( "x", [ np.ones(5), np.array(5), np.random.random((5, 5)), np.random.random((5, 5))[::2, :], np.random.random((5, 5))[:, ::2], np.asfortranarray(np.random.random((5, 5))), np.asfortranarray(np.random.random((5, 5)))[::2, :], np.asfortranarray(np.random.random((5, 5)))[:, ::2], np.random.random(5).astype("f4"), np.random.random(5).astype(">i8"), np.random.random(5).astype("<i8"), np.arange(5).astype("M8[us]"), np.arange(5).astype("M8[ms]"), np.arange(5).astype("m8"), np.arange(5).astype("m8[s]"), np.arange(5).astype("c16"), np.arange(5).astype("c8"), np.array([True, False, True]), np.ones(shape=5, dtype=[("a", "i4"), ("b", "M8[us]")]), np.array(["abc"], dtype="S3"), np.array(["abc"], dtype="U3"), np.array(["abc"], dtype=object), np.array([np.arange(3), np.arange(4, 6)], dtype=object), np.ones(shape=(5,), dtype=("f8", 32)), np.ones(shape=(5,), dtype=[("x", "f8", 32)]), np.ones(shape=(5,), dtype=np.dtype([("a", "i1"), ("b", "f8")], align=False)), np.ones(shape=(5,), dtype=np.dtype([("a", "i1"), ("b", "f8")], align=True)), np.ones(shape=(5,), dtype=np.dtype([("a", "m8[us]")], align=False)), # this dtype fails unpickling np.ones(shape=(5,), dtype=np.dtype([("a", "m8")], align=False)), np.array([(1, "abc")], dtype=[("x", "i4"), ("s", object)]), np.zeros(5000, dtype=[("x%d" % i, "<f8") for i in range(4)]), np.zeros(5000, dtype="S32"), np.zeros((1, 1000, 1000)), np.arange(12)[::2], # non-contiguous array np.ones(shape=(5, 6)).astype(dtype=[("total", "<f8"), ("n", "<f8")]), np.broadcast_to(np.arange(3), shape=(10, 3)), # zero-strided array ], )
def test_dumps_serialize_numpy(x)