Skip to content

Commit a8b7b46

Browse files
committed
add test for orthogonal indexing
1 parent 84099f3 commit a8b7b46

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

xarray/tests/test_async.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import xarray.testing as xrt
1212
from xarray.tests import has_zarr_v3, requires_zarr_v3
1313

14-
1514
if has_zarr_v3:
1615
import zarr
1716
from zarr.abc.store import ByteRequest, Store
@@ -77,25 +76,25 @@ async def get_partial_values(
7776
@pytest.fixture
7877
def memorystore() -> "MemoryStore":
7978
memorystore = zarr.storage.MemoryStore({})
80-
z = zarr.create_array(
79+
z1 = zarr.create_array(
8180
store=memorystore,
8281
name="foo",
8382
shape=(10, 10),
8483
chunks=(5, 5),
8584
dtype="f4",
8685
dimension_names=["x", "y"],
8786
)
88-
z[:, :] = np.random.random((10, 10))
87+
z1[:, :] = np.random.random((10, 10))
8988

90-
z = zarr.create_array(
89+
z2 = zarr.create_array(
9190
store=memorystore,
92-
name="bar",
91+
name="x",
9392
shape=(10,),
9493
chunks=(5),
9594
dtype="f4",
9695
dimension_names=["x"],
9796
)
98-
z[:] = np.random.random((10,))
97+
z2[:] = np.arange(10)
9998

10099
return memorystore
101100

@@ -123,7 +122,7 @@ async def measure(self):
123122
class TestAsyncLoad:
124123
LATENCY: float = 1.0
125124

126-
@pytest.fixture(params=["ds", "da", "var"])
125+
@pytest.fixture(params=["var", "ds", "da"])
127126
def xr_obj(self, request, memorystore) -> xr.Dataset | xr.DataArray | xr.Variable:
128127
latencystore = LatencyStore(memorystore, latency=self.LATENCY)
129128
ds = xr.open_zarr(latencystore, zarr_format=3, consolidated=False, chunks=None)
@@ -175,3 +174,17 @@ async def test_concurrent_load_multiple_objects(self, xr_obj) -> None:
175174
self.assert_time_as_expected(
176175
total_time=timer.total_time, latency=self.LATENCY, n_loads=N_OBJECTS
177176
)
177+
178+
@pytest.mark.xfail(reason="not implemented")
179+
async def test_indexing(self, memorystore) -> None:
180+
latencystore = LatencyStore(memorystore, latency=self.LATENCY)
181+
ds = xr.open_zarr(latencystore, zarr_format=3, consolidated=False, chunks=None)
182+
183+
# TODO test basic indexing
184+
185+
# test orthogonal indexing
186+
indexer = {"x": [2, 3]}
187+
result = await ds.sel(indexer).load_async()
188+
xrt.assert_identical(result, ds.sel(indexer).load())
189+
190+
# TODO test vectorized indexing

0 commit comments

Comments
 (0)