Skip to content

Commit ec2bc94

Browse files
authored
Merge branch 'master' into fix-vecmat-win-failure
2 parents 31ee230 + 131c490 commit ec2bc94

File tree

9 files changed

+13
-47
lines changed

9 files changed

+13
-47
lines changed

.github/workflows/openssf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@ jobs:
7272

7373
# Upload the results to GitHub's code scanning dashboard.
7474
- name: "Upload to code-scanning"
75-
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
75+
uses: github/codeql-action/upload-sarif@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
7676
with:
7777
sarif_file: results.sarif

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ repos:
6464
additional_dependencies:
6565
- tomli
6666
- repo: https://github.com/psf/black
67-
rev: 25.9.0
67+
rev: 25.11.0
6868
hooks:
6969
- id: black
7070
exclude: "dpnp/_version.py"

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
@@ -3013,7 +3013,7 @@ def require(a, dtype=None, requirements=None, *, like=None):
30133013
return arr
30143014

30153015

3016-
def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
3016+
def reshape(a, /, shape=None, order="C", *, copy=None):
30173017
"""
30183018
Gives a new shape to an array without changing its data.
30193019
@@ -3045,10 +3045,6 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
30453045
Fortran *contiguous* in memory, C-like order otherwise.
30463046
30473047
Default: ``"C"``.
3048-
newshape : int or tuple of ints
3049-
Replaced by `shape` argument. Retained for backward compatibility.
3050-
3051-
Default: ``None``.
30523048
copy : {None, bool}, optional
30533049
If ``True``, then the array data is copied. If ``None``, a copy will
30543050
only be made if it's required by ``order``. For ``False`` it raises
@@ -3117,27 +3113,11 @@ def reshape(a, /, shape=None, order="C", *, newshape=None, copy=None):
31173113
31183114
"""
31193115

3120-
if newshape is None and shape is None:
3116+
if shape is None:
31213117
raise TypeError(
31223118
"reshape() missing 1 required positional argument: 'shape'"
31233119
)
31243120

3125-
if newshape is not None:
3126-
if shape is not None:
3127-
raise TypeError(
3128-
"You cannot specify 'newshape' and 'shape' arguments "
3129-
"at the same time."
3130-
)
3131-
# Deprecated in dpnp 0.17.0
3132-
warnings.warn(
3133-
"`newshape` keyword argument is deprecated, "
3134-
"use `shape=...` or pass shape positionally instead. "
3135-
"(deprecated in dpnp 0.17.0)",
3136-
DeprecationWarning,
3137-
stacklevel=2,
3138-
)
3139-
shape = newshape
3140-
31413121
if order is None:
31423122
order = "C"
31433123
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
@@ -12,7 +12,6 @@
1212
assert_dtype_allclose,
1313
generate_random_numpy_array,
1414
get_all_dtypes,
15-
is_ptl,
1615
numpy_version,
1716
)
1817
from .third_party.cupy import testing
@@ -1152,7 +1151,6 @@ def test_large_values(self, dtype):
11521151
expected = numpy.matmul(a, b)
11531152
assert_dtype_allclose(result, expected)
11541153

1155-
@pytest.mark.skipif(is_ptl(), reason="MKLD-18712")
11561154
@pytest.mark.parametrize("dt_out", [numpy.int32, numpy.float32])
11571155
@pytest.mark.parametrize(
11581156
"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)