|
11 | 11 | import xarray.testing as xrt |
12 | 12 | from xarray.tests import has_zarr_v3, requires_zarr_v3 |
13 | 13 |
|
14 | | - |
15 | 14 | if has_zarr_v3: |
16 | 15 | import zarr |
17 | 16 | from zarr.abc.store import ByteRequest, Store |
@@ -77,25 +76,25 @@ async def get_partial_values( |
77 | 76 | @pytest.fixture |
78 | 77 | def memorystore() -> "MemoryStore": |
79 | 78 | memorystore = zarr.storage.MemoryStore({}) |
80 | | - z = zarr.create_array( |
| 79 | + z1 = zarr.create_array( |
81 | 80 | store=memorystore, |
82 | 81 | name="foo", |
83 | 82 | shape=(10, 10), |
84 | 83 | chunks=(5, 5), |
85 | 84 | dtype="f4", |
86 | 85 | dimension_names=["x", "y"], |
87 | 86 | ) |
88 | | - z[:, :] = np.random.random((10, 10)) |
| 87 | + z1[:, :] = np.random.random((10, 10)) |
89 | 88 |
|
90 | | - z = zarr.create_array( |
| 89 | + z2 = zarr.create_array( |
91 | 90 | store=memorystore, |
92 | | - name="bar", |
| 91 | + name="x", |
93 | 92 | shape=(10,), |
94 | 93 | chunks=(5), |
95 | 94 | dtype="f4", |
96 | 95 | dimension_names=["x"], |
97 | 96 | ) |
98 | | - z[:] = np.random.random((10,)) |
| 97 | + z2[:] = np.arange(10) |
99 | 98 |
|
100 | 99 | return memorystore |
101 | 100 |
|
@@ -123,7 +122,7 @@ async def measure(self): |
123 | 122 | class TestAsyncLoad: |
124 | 123 | LATENCY: float = 1.0 |
125 | 124 |
|
126 | | - @pytest.fixture(params=["ds", "da", "var"]) |
| 125 | + @pytest.fixture(params=["var", "ds", "da"]) |
127 | 126 | def xr_obj(self, request, memorystore) -> xr.Dataset | xr.DataArray | xr.Variable: |
128 | 127 | latencystore = LatencyStore(memorystore, latency=self.LATENCY) |
129 | 128 | 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: |
175 | 174 | self.assert_time_as_expected( |
176 | 175 | total_time=timer.total_time, latency=self.LATENCY, n_loads=N_OBJECTS |
177 | 176 | ) |
| 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