Skip to content

Commit b210970

Browse files
Merge master into refactor_public_api_exports
2 parents ebe02a8 + 131c490 commit b210970

File tree

7 files changed

+11
-45
lines changed

7 files changed

+11
-45
lines changed

CHANGELOG.md

Lines changed: 2 additions & 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

@@ -46,6 +47,7 @@ Also, that release drops support for Python 3.9, making Python 3.10 the minimum
4647

4748
* Dropped support for Python 3.9 [#2626](https://github.com/IntelPython/dpnp/pull/2626)
4849
* Removed the obsolete interface from DPNP to Numba JIT [#2647](https://github.com/IntelPython/dpnp/pull/2647)
50+
* Removed the `newshape` parameter from `dpnp.reshape`, which has been deprecated since dpnp 0.17.0. Pass it positionally or use `shape=` on newer versions [#2670](https://github.com/IntelPython/dpnp/pull/2670)
4951

5052
### Fixed
5153

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/dpnp_iface_manipulation.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,7 @@ def require(a, dtype=None, requirements=None, *, like=None):
29502950
return arr
29512951

29522952

2953-
def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
2953+
def reshape(a, /, shape=None, order="C", *, copy=None):
29542954
"""
29552955
Gives a new shape to an array without changing its data.
29562956
@@ -2982,10 +2982,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
29822982
Fortran *contiguous* in memory, C-like order otherwise.
29832983
29842984
Default: ``"C"``.
2985-
newshape : int or tuple of ints
2986-
Replaced by `shape` argument. Retained for backward compatibility.
2987-
2988-
Default: ``None``.
29892985
copy : {None, bool}, optional
29902986
If ``True``, then the array data is copied. If ``None``, a copy will
29912987
only be made if it's required by ``order``. For ``False`` it raises
@@ -3054,27 +3050,11 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
30543050
30553051
"""
30563052

3057-
if newshape is None and shape is None:
3053+
if shape is None:
30583054
raise TypeError(
30593055
"reshape() missing 1 required positional argument: 'shape'"
30603056
)
30613057

3062-
if newshape is not None:
3063-
if shape is not None:
3064-
raise TypeError(
3065-
"You cannot specify 'newshape' and 'shape' arguments "
3066-
"at the same time."
3067-
)
3068-
# Deprecated in dpnp 0.17.0
3069-
warnings.warn(
3070-
"`newshape` keyword argument is deprecated, "
3071-
"use `shape=...` or pass shape positionally instead. "
3072-
"(deprecated in dpnp 0.17.0)",
3073-
DeprecationWarning,
3074-
stacklevel=2,
3075-
)
3076-
shape = newshape
3077-
30783058
if order is None:
30793059
order = "C"
30803060
elif order in "aA":

dpnp/tests/test_manipulation.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,21 +1124,6 @@ def test_copy(self):
11241124

11251125

11261126
class TestReshape:
1127-
def test_error(self):
1128-
ia = dpnp.arange(10)
1129-
assert_raises(TypeError, dpnp.reshape, ia)
1130-
assert_raises(
1131-
TypeError, dpnp.reshape, ia, shape=(2, 5), newshape=(2, 5)
1132-
)
1133-
1134-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
1135-
def test_newshape(self):
1136-
a = numpy.arange(10)
1137-
ia = dpnp.array(a)
1138-
expected = numpy.reshape(a, (2, 5))
1139-
result = dpnp.reshape(ia, newshape=(2, 5))
1140-
assert_array_equal(result, expected)
1141-
11421127
@pytest.mark.parametrize("order", [None, "C", "F", "A"])
11431128
def test_order(self, order):
11441129
a = numpy.arange(10)

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)