| 5100 | |
| 5101 | |
| 5102 | def test_zarr_group(): |
| 5103 | zarr = pytest.importorskip("zarr") |
| 5104 | with tmpdir() as d: |
| 5105 | a = da.zeros((3, 3), chunks=(1, 1)) |
| 5106 | a.to_zarr(d, component="test") |
| 5107 | with pytest.raises((OSError, ValueError)): |
| 5108 | a.to_zarr(d, component="test", **{"overwrite": False}) |
| 5109 | a.to_zarr(d, component="test", **{"overwrite": True}) |
| 5110 | |
| 5111 | # second time is fine, group exists |
| 5112 | a.to_zarr(d, component="test2", **{"overwrite": False}) |
| 5113 | a.to_zarr(d, component="nested/test", **{"overwrite": False}) |
| 5114 | |
| 5115 | group = zarr.open_group(store=d, mode="r") |
| 5116 | assert set(group) == {"nested", "test", "test2"} |
| 5117 | assert "test" in group["nested"] |
| 5118 | |
| 5119 | a2 = da.from_zarr(d, component="test") |
| 5120 | assert_eq(a, a2) |
| 5121 | assert a2.chunks == a.chunks |
| 5122 | |
| 5123 | |
| 5124 | @pytest.mark.parametrize( |