From d9c3646bfc53dfd37eb921f6af8fc533d029d9d3 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sun, 29 Jun 2025 10:39:30 +0200 Subject: [PATCH 1/2] BUG: torch/meshgrid: stop ignoring the "indexing" argument --- array_api_compat/torch/_aliases.py | 2 +- tests/test_torch.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/array_api_compat/torch/_aliases.py b/array_api_compat/torch/_aliases.py index 91161d24..40960f45 100644 --- a/array_api_compat/torch/_aliases.py +++ b/array_api_compat/torch/_aliases.py @@ -826,7 +826,7 @@ def sign(x: Array, /) -> Array: def meshgrid(*arrays: Array, indexing: Literal['xy', 'ij'] = 'xy') -> list[Array]: # enforce the default of 'xy' # TODO: is the return type a list or a tuple - return list(torch.meshgrid(*arrays, indexing='xy')) + return list(torch.meshgrid(*arrays, indexing=indexing)) __all__ = ['asarray', 'result_type', 'can_cast', diff --git a/tests/test_torch.py b/tests/test_torch.py index 7adb4ab3..f661a272 100644 --- a/tests/test_torch.py +++ b/tests/test_torch.py @@ -117,3 +117,16 @@ def test_meshgrid(): assert Y.shape == Y_xy.shape assert xp.all(Y == Y_xy) + + # repeat with an explicit indexing + X, Y = xp.meshgrid(x, y, indexing='ij') + + # output of torch.meshgrid(x, y, indexing='ij') + X_ij, Y_ij = xp.asarray([[1], [2]]), xp.asarray([[4], [4]]) + + assert X.shape == X_ij.shape + assert xp.all(X == X_ij) + + assert Y.shape == Y_ij.shape + assert xp.all(Y == Y_ij) + From fa35e90a1b56a8338372373064af67c47db945f5 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Sun, 29 Jun 2025 11:54:16 +0200 Subject: [PATCH 2/2] CI: some dask tests require numpy >= 3.12 --- tests/test_dask.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_dask.py b/tests/test_dask.py index fb0a84d4..4200e5b7 100644 --- a/tests/test_dask.py +++ b/tests/test_dask.py @@ -1,3 +1,4 @@ +import sys from contextlib import contextmanager import numpy as np @@ -167,6 +168,10 @@ def test_sort_argsort_chunk_size(xp, func, shape, chunks): ) +@pytest.mark.skipif( + sys.version_info.major*100 + sys.version_info.minor < 312, + reason="dask interop requires numpy >= 3.12" +) @pytest.mark.parametrize("func", ["sort", "argsort"]) def test_sort_argsort_meta(xp, func): """Test meta-namespace other than numpy""" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy