Skip to content

Commit c0ae882

Browse files
committed
Added datatree leading slash to encoding
1 parent 3c01594 commit c0ae882

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/topozarr/coarsen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def create_pyramid(
6060
if "spatial_ref" in ds_level.coords:
6161
ds_level = ds_level.drop_vars("spatial_ref")
6262

63-
path = str(idx)
64-
dt[path] = DataTree(ds_level, name=path)
63+
name = str(idx)
64+
path = f"/{idx}"
65+
dt[path] = DataTree(ds_level, name=name)
6566
full_encoding[path] = create_level_encoding(
6667
ds_level,
6768
x_dim,

tests/test_chunking.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_chunk_size_overrides(create_dataset):
3232
pyramid_small = create_pyramid(ds, levels=1, target_chunk_bytes=1024)
3333
pyramid_large = create_pyramid(ds, levels=1, target_chunk_bytes=10 * 1024 * 1024)
3434

35-
chunk_small = pyramid_small.encoding["0"]["elevation"]["chunks"]
36-
chunk_large = pyramid_large.encoding["0"]["elevation"]["chunks"]
35+
chunk_small = pyramid_small.encoding["/0"]["elevation"]["chunks"]
36+
chunk_large = pyramid_large.encoding["/0"]["elevation"]["chunks"]
3737

3838
assert chunk_small[0] < chunk_large[0]
3939

@@ -48,5 +48,5 @@ def test_shard_size_overrides(create_dataset):
4848
ds, levels=1, target_chunk_bytes=target, target_shard_bytes=target
4949
)
5050

51-
enc = pyramid.encoding["0"]["elevation"]
51+
enc = pyramid.encoding["/0"]["elevation"]
5252
assert enc["chunks"] == enc["shards"]

tests/test_specs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_encoding_contains_shards(create_dataset):
4444
ds = create_dataset(nx=1000, ny=1000)
4545
pyramid = create_pyramid(ds, levels=1)
4646

47-
enc = pyramid.encoding["0"]["elevation"]
47+
enc = pyramid.encoding["/0"]["elevation"]
4848
assert "chunks" in enc
4949
assert "shards" in enc
5050
assert all(shard >= chunk for shard, chunk in zip(enc["shards"], enc["chunks"]))

0 commit comments

Comments
 (0)