Skip to content

Commit d6c0cba

Browse files
committed
Add more testing with different order values
1 parent 2bbf9f3 commit d6c0cba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dpnp/tests/test_ndarray.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ def test_strides(self):
108108
assert xp.full_like(a, fill_value=6) not in a
109109

110110

111+
class TestToBytes:
112+
@pytest.mark.parametrize("order", ["C", "F", "K", "A", None])
113+
def test_roundtrip_binary_str(self, order):
114+
x = generate_random_numpy_array((2, 4, 3), dtype=complex)
115+
x[0, :, 1] = [numpy.nan, numpy.inf, -numpy.inf, numpy.nan]
116+
a = dpnp.array(x)
117+
118+
s = a.tobytes(order=order)
119+
b = dpnp.frombuffer(s, dtype=a.dtype)
120+
assert_array_equal(b, a.asnumpy().flatten(order))
121+
122+
111123
class TestToFile:
112124
def _create_data(self):
113125
x = generate_random_numpy_array((2, 4, 3), dtype=complex)

0 commit comments

Comments
 (0)