diff --git a/CHANGELOG.md b/CHANGELOG.md index d6239fd9c1f5..af415bc1dc54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Changed +* Changed `dpnp.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) ### Deprecated diff --git a/dpnp/dpnp_iface_arraycreation.py b/dpnp/dpnp_iface_arraycreation.py index 31be7a8c2768..5a245c690379 100644 --- a/dpnp/dpnp_iface_arraycreation.py +++ b/dpnp/dpnp_iface_arraycreation.py @@ -3111,7 +3111,7 @@ def meshgrid(*xi, copy=True, sparse=False, indexing="xy"): ) if ndim < 1: - return [] + return () s0 = (1,) * ndim output = [ @@ -3132,7 +3132,7 @@ def meshgrid(*xi, copy=True, sparse=False, indexing="xy"): if copy: output = [dpt.copy(x) for x in output] - return [dpnp_array._create_from_usm_ndarray(x) for x in output] + return tuple(dpnp_array._create_from_usm_ndarray(x) for x in output) class MGridClass: diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index b195c0484105..5a9a1c73c6e0 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -984,13 +984,19 @@ def test_dpctl_tensor_input(func, args): [[], [[1]], [[1, 2, 3], [4, 5, 6]], [[1, 2], [3, 4], [5, 6]]], ids=["[]", "[[1]]", "[[1, 2, 3], [4, 5, 6]]", "[[1, 2], [3, 4], [5, 6]]"], ) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_none=True, no_float16=False) +) @pytest.mark.parametrize("indexing", ["ij", "xy"]) def test_meshgrid(arrays, dtype, indexing): func = lambda xp, xi: xp.meshgrid(*xi, indexing=indexing) a = tuple(numpy.array(array, dtype=dtype) for array in arrays) ia = tuple(dpnp.array(array, dtype=dtype) for array in arrays) - assert_array_equal(func(numpy, a), func(dpnp, ia)) + + result = func(dpnp, ia) + expected = func(numpy, a) + assert_array_equal(result, expected, strict=True) + assert isinstance(result, tuple) @pytest.mark.parametrize("shape", [(24,), (4, 6), (2, 3, 4), (2, 3, 2, 2)]) diff --git a/dpnp/tests/third_party/cupy/creation_tests/test_ranges.py b/dpnp/tests/third_party/cupy/creation_tests/test_ranges.py index 69873473e0d7..ce716b10dd37 100644 --- a/dpnp/tests/third_party/cupy/creation_tests/test_ranges.py +++ b/dpnp/tests/third_party/cupy/creation_tests/test_ranges.py @@ -344,7 +344,7 @@ def test_meshgrid0(self, dtype): out = cupy.meshgrid( indexing=self.indexing, sparse=self.sparse, copy=self.copy ) - assert out == [] + assert out == () @testing.for_all_dtypes() @testing.numpy_cupy_array_equal()