(self)
| 4120 | yield {} |
| 4121 | |
| 4122 | def test_chunk_key_encoding_v2(self) -> None: |
| 4123 | encoding = {"name": "v2", "configuration": {"separator": "/"}} |
| 4124 | |
| 4125 | # Create a dataset with a variable name containing a period |
| 4126 | data = np.ones((4, 4)) |
| 4127 | original = Dataset({"var1": (("x", "y"), data)}) |
| 4128 | |
| 4129 | # Set up chunk key encoding with slash separator |
| 4130 | encoding = { |
| 4131 | "var1": { |
| 4132 | "chunk_key_encoding": encoding, |
| 4133 | "chunks": (2, 2), |
| 4134 | } |
| 4135 | } |
| 4136 | |
| 4137 | # Write to store with custom encoding |
| 4138 | with self.create_zarr_target() as store: |
| 4139 | original.to_zarr(store, encoding=encoding) |
| 4140 | |
| 4141 | # Verify the chunk keys in store use the slash separator |
| 4142 | if not has_zarr_v3: |
| 4143 | chunk_keys = [k for k in store.keys() if k.startswith("var1/")] |
| 4144 | assert len(chunk_keys) > 0 |
| 4145 | for key in chunk_keys: |
| 4146 | assert "/" in key |
| 4147 | assert "." not in key.split("/")[1:] # No dots in chunk coordinates |
| 4148 | |
| 4149 | # Read back and verify data |
| 4150 | with xr.open_zarr(store) as actual: |
| 4151 | assert_identical(original, actual) |
| 4152 | # Verify chunks are preserved |
| 4153 | assert actual["var1"].encoding["chunks"] == (2, 2) |
| 4154 | |
| 4155 | @pytest.mark.asyncio |
| 4156 | @requires_zarr_v3 |
nothing calls this directly
no test coverage detected