Skip to content

Commit 56331e2

Browse files
Merge master into require_shape_in_reshape
2 parents bcb52bb + 131c490 commit 56331e2

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
2424
* Extended `pre-commit` configuration with `pyupgrade`, `actionlint`, and `gersemi` hooks [#2658](https://github.com/IntelPython/dpnp/pull/2658)
2525
* Added implementation of `dpnp.ndarray.tobytes` method [#2656](https://github.com/IntelPython/dpnp/pull/2656)
2626
* Added implementation of `dpnp.ndarray.__format__` method [#2662](https://github.com/IntelPython/dpnp/pull/2662)
27+
* Added implementation of `dpnp.ndarray.__bytes__` method [#2671](https://github.com/IntelPython/dpnp/pull/2671)
2728

2829
### Changed
2930

doc/reference/ndarray.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ and return the appropriate scalar.
436436
:toctree: generated/
437437
:nosignatures:
438438

439+
ndarray.__bytes__
439440
ndarray.__index__
440441
ndarray.__int__
441442
ndarray.__float__

dpnp/dpnp_array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ def __bool__(self, /):
185185
"""``True`` if `self` else ``False``."""
186186
return self._array_obj.__bool__()
187187

188+
def __bytes__(self):
189+
r"""Return :math:`\text{bytes(self)}`."""
190+
return bytes(self.asnumpy())
191+
188192
# '__class__',
189193
# `__class_getitem__`,
190194

dpnp/tests/test_product.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
generate_random_numpy_array,
1414
get_all_dtypes,
1515
is_gpu_device,
16-
is_ptl,
1716
is_win_platform,
1817
numpy_version,
1918
)
@@ -1154,7 +1153,6 @@ def test_large_values(self, dtype):
11541153
expected = numpy.matmul(a, b)
11551154
assert_dtype_allclose(result, expected)
11561155

1157-
@pytest.mark.skipif(is_ptl(), reason="MKLD-18712")
11581156
@pytest.mark.parametrize("dt_out", [numpy.int32, numpy.float32])
11591157
@pytest.mark.parametrize(
11601158
"shape1, shape2",

dpnp/tests/third_party/cupy/core_tests/test_ndarray.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,32 +653,28 @@ def test_size_zero_dim_array_with_axis(self):
653653

654654
class TestPythonInterface(unittest.TestCase):
655655

656-
@pytest.mark.skip("__bytes__ is not supported")
657656
@testing.for_all_dtypes()
658657
@testing.numpy_cupy_equal()
659658
def test_bytes_tobytes(self, xp, dtype):
660659
x = testing.shaped_arange((3, 4, 5), xp, dtype)
661660
return bytes(x)
662661

663-
@pytest.mark.skip("__bytes__ is not supported")
664662
@testing.for_all_dtypes()
665663
@testing.numpy_cupy_equal()
666664
def test_bytes_tobytes_empty(self, xp, dtype):
667-
x = xp.empty((0,), dtype)
665+
x = xp.empty((0,), dtype=dtype)
668666
return bytes(x)
669667

670-
@pytest.mark.skip("__bytes__ is not supported")
671668
@testing.for_all_dtypes()
672669
@testing.numpy_cupy_equal()
673670
def test_bytes_tobytes_empty2(self, xp, dtype):
674-
x = xp.empty((3, 0, 4), dtype)
671+
x = xp.empty((3, 0, 4), dtype=dtype)
675672
return bytes(x)
676673

677674
# The result of bytes(numpy.array(scalar)) is the same as bytes(scalar)
678675
# if scalar is of an integer dtype including bool_. It's spec is
679676
# bytes(int): bytes object of size given by the parameter initialized with
680677
# null bytes.
681-
@pytest.mark.skip("__bytes__ is not supported")
682678
@testing.for_float_dtypes()
683679
@testing.numpy_cupy_equal()
684680
def test_bytes_tobytes_scalar_array(self, xp, dtype):

0 commit comments

Comments
 (0)