Skip to content

Commit d5fb584

Browse files
authored
Merge branch 'master' into fix-fork-pr-docs-workflow
2 parents 05cc1cb + 6ec4ddc commit d5fb584

6 files changed

Lines changed: 19 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
### Changed
12+
* Changed `dpnp.meshgrid` and `dpnp.tensor.meshgrid` to return a tuple instead of a list, aligning with NumPy 2.5+ behavior and 2025.12 version of the Python array API standard [#2854](https://github.com/IntelPython/dpnp/pull/2854)
1213

1314
### Deprecated
1415

dpnp/dpnp_iface_arraycreation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,7 +3111,7 @@ def meshgrid(*xi, copy=True, sparse=False, indexing="xy"):
31113111
)
31123112

31133113
if ndim < 1:
3114-
return []
3114+
return ()
31153115

31163116
s0 = (1,) * ndim
31173117
output = [
@@ -3132,7 +3132,7 @@ def meshgrid(*xi, copy=True, sparse=False, indexing="xy"):
31323132
if copy:
31333133
output = [dpt.copy(x) for x in output]
31343134

3135-
return [dpnp_array._create_from_usm_ndarray(x) for x in output]
3135+
return tuple(dpnp_array._create_from_usm_ndarray(x) for x in output)
31363136

31373137

31383138
class MGridClass:

dpnp/tensor/_ctors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ def linspace(
14411441

14421442
def meshgrid(*arrays, indexing="xy"):
14431443
"""
1444-
Creates list of :class:`dpctl.tensor.usm_ndarray` coordinate matrices
1444+
Creates tuple of :class:`dpctl.tensor.usm_ndarray` coordinate matrices
14451445
from vectors.
14461446
14471447
Args:
@@ -1456,8 +1456,8 @@ def meshgrid(*arrays, indexing="xy"):
14561456
keyword has no effect and should be ignored. Default: ``"xy"``
14571457
14581458
Returns:
1459-
List[array]:
1460-
list of ``N`` arrays, where ``N`` is the number of
1459+
Tuple[array]:
1460+
tuple of ``N`` arrays, where ``N`` is the number of
14611461
provided one-dimensional input arrays. Each returned array must
14621462
have rank ``N``.
14631463
For a set of ``n`` vectors with lengths ``N0``, ``N1``, ``N2``, ...
@@ -1495,7 +1495,7 @@ def meshgrid(*arrays, indexing="xy"):
14951495
)
14961496
n = len(arrays)
14971497
if n == 0:
1498-
return []
1498+
return ()
14991499

15001500
sh = (-1,) + (1,) * (n - 1)
15011501

@@ -1511,7 +1511,7 @@ def meshgrid(*arrays, indexing="xy"):
15111511

15121512
output = dpt.broadcast_arrays(*res)
15131513

1514-
return output
1514+
return tuple(output)
15151515

15161516

15171517
def ones(

dpnp/tests/tensor/test_usm_ndarray_ctor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,8 @@ def test_meshgrid():
19241924
assert n == len(Znp)
19251925
for i in range(n):
19261926
assert np.array_equal(dpt.asnumpy(Z[i]), Znp[i])
1927-
assert dpt.meshgrid() == []
1927+
assert isinstance(Z, tuple)
1928+
assert dpt.meshgrid() == ()
19281929
# dimension > 1 must raise ValueError
19291930
with pytest.raises(ValueError):
19301931
dpt.meshgrid(dpt.usm_ndarray((4, 4)))

dpnp/tests/test_arraycreation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,19 @@ def test_dpctl_tensor_input(func, args):
984984
[[], [[1]], [[1, 2, 3], [4, 5, 6]], [[1, 2], [3, 4], [5, 6]]],
985985
ids=["[]", "[[1]]", "[[1, 2, 3], [4, 5, 6]]", "[[1, 2], [3, 4], [5, 6]]"],
986986
)
987-
@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False))
987+
@pytest.mark.parametrize(
988+
"dtype", get_all_dtypes(no_none=True, no_float16=False)
989+
)
988990
@pytest.mark.parametrize("indexing", ["ij", "xy"])
989991
def test_meshgrid(arrays, dtype, indexing):
990992
func = lambda xp, xi: xp.meshgrid(*xi, indexing=indexing)
991993
a = tuple(numpy.array(array, dtype=dtype) for array in arrays)
992994
ia = tuple(dpnp.array(array, dtype=dtype) for array in arrays)
993-
assert_array_equal(func(numpy, a), func(dpnp, ia))
995+
996+
result = func(dpnp, ia)
997+
expected = func(numpy, a)
998+
assert_array_equal(result, expected, strict=True)
999+
assert isinstance(result, tuple)
9941000

9951001

9961002
@pytest.mark.parametrize("shape", [(24,), (4, 6), (2, 3, 4), (2, 3, 2, 2)])

dpnp/tests/third_party/cupy/creation_tests/test_ranges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def test_meshgrid0(self, dtype):
344344
out = cupy.meshgrid(
345345
indexing=self.indexing, sparse=self.sparse, copy=self.copy
346346
)
347-
assert out == []
347+
assert out == ()
348348

349349
@testing.for_all_dtypes()
350350
@testing.numpy_cupy_array_equal()

0 commit comments

Comments
 (0)