Skip to content

Commit 6001e93

Browse files
committed
fix tests that expected codecs==["bytes"]
1 parent 80dfc40 commit 6001e93

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

tests/test_array.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import zarr.api.asynchronous
1414
from zarr import Array, AsyncArray, Group
15-
from zarr.codecs import BytesCodec, VLenBytesCodec
15+
from zarr.codecs import BytesCodec, VLenBytesCodec, ZstdCodec
1616
from zarr.core._info import ArrayInfo
1717
from zarr.core.array import chunks_initialized
1818
from zarr.core.buffer import default_buffer_prototype
@@ -376,7 +376,7 @@ async def test_chunks_initialized() -> None:
376376

377377

378378
def test_nbytes_stored() -> None:
379-
arr = zarr.create(shape=(100,), chunks=(10,), dtype="i4")
379+
arr = zarr.create(shape=(100,), chunks=(10,), dtype="i4", codecs=[BytesCodec()])
380380
result = arr.nbytes_stored()
381381
assert result == 366 # the size of the metadata document. This is a fragile test.
382382
arr[:50] = 1
@@ -388,7 +388,9 @@ def test_nbytes_stored() -> None:
388388

389389

390390
async def test_nbytes_stored_async() -> None:
391-
arr = await zarr.api.asynchronous.create(shape=(100,), chunks=(10,), dtype="i4")
391+
arr = await zarr.api.asynchronous.create(
392+
shape=(100,), chunks=(10,), dtype="i4", codecs=[BytesCodec()]
393+
)
392394
result = await arr.nbytes_stored()
393395
assert result == 366 # the size of the metadata document. This is a fragile test.
394396
await arr.setitem(slice(50), 1)
@@ -473,13 +475,13 @@ def test_info_v3(self) -> None:
473475
_order="C",
474476
_read_only=False,
475477
_store_type="MemoryStore",
476-
_codecs=[BytesCodec()],
478+
_codecs=[BytesCodec(), ZstdCodec()],
477479
_count_bytes=128,
478480
)
479481
assert result == expected
480482

481483
def test_info_complete(self) -> None:
482-
arr = zarr.create(shape=(4, 4), chunks=(2, 2), zarr_format=3)
484+
arr = zarr.create(shape=(4, 4), chunks=(2, 2), zarr_format=3, codecs=[BytesCodec()])
483485
result = arr.info_complete()
484486
expected = ArrayInfo(
485487
_zarr_format=3,
@@ -530,13 +532,15 @@ async def test_info_v3_async(self) -> None:
530532
_order="C",
531533
_read_only=False,
532534
_store_type="MemoryStore",
533-
_codecs=[BytesCodec()],
535+
_codecs=[BytesCodec(), ZstdCodec()],
534536
_count_bytes=128,
535537
)
536538
assert result == expected
537539

538540
async def test_info_complete_async(self) -> None:
539-
arr = await zarr.api.asynchronous.create(shape=(4, 4), chunks=(2, 2), zarr_format=3)
541+
arr = await zarr.api.asynchronous.create(
542+
shape=(4, 4), chunks=(2, 2), zarr_format=3, codecs=[BytesCodec()]
543+
)
540544
result = await arr.info_complete()
541545
expected = ArrayInfo(
542546
_zarr_format=3,

tests/test_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def test_config_defaults_set() -> None:
5656
"string": "vlen-utf8",
5757
"bytes": "vlen-bytes",
5858
},
59+
"v3_default_codecs": {
60+
"bytes": ["vlen-bytes"],
61+
"numeric": ["bytes", "zstd"],
62+
"string": ["vlen-utf8"],
63+
},
5964
},
6065
"async": {"concurrency": 10, "timeout": None},
6166
"threading": {"max_workers": None},

tests/test_group.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ def test_group_child_iterators(store: Store, zarr_format: ZarrFormat, consolidat
523523
"configuration": {"separator": "/"},
524524
"name": "default",
525525
},
526-
"codecs": ({"configuration": {"endian": "little"}, "name": "bytes"},),
526+
"codecs": (
527+
{"configuration": {"endian": "little"}, "name": "bytes"},
528+
{"configuration": {}, "name": "zstd"},
529+
),
527530
"data_type": "float64",
528531
"fill_value": fill_value,
529532
"node_type": "array",

tests/test_metadata/test_consolidated.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ async def test_consolidated(self, memory_store_with_hierarchy: Store) -> None:
7272
"configuration": {"separator": "/"},
7373
"name": "default",
7474
},
75-
"codecs": ({"configuration": {"endian": "little"}, "name": "bytes"},),
75+
"codecs": (
76+
{"configuration": {"endian": "little"}, "name": "bytes"},
77+
{"configuration": {}, "name": "zstd"},
78+
),
7679
"data_type": "float64",
7780
"fill_value": np.float64(0.0),
7881
"node_type": "array",
@@ -216,7 +219,10 @@ def test_consolidated_sync(self, memory_store):
216219
"configuration": {"separator": "/"},
217220
"name": "default",
218221
},
219-
"codecs": ({"configuration": {"endian": "little"}, "name": "bytes"},),
222+
"codecs": (
223+
{"configuration": {"endian": "little"}, "name": "bytes"},
224+
{"configuration": {}, "name": "zstd"},
225+
),
220226
"data_type": "float64",
221227
"fill_value": np.float64(0.0),
222228
"node_type": "array",

0 commit comments

Comments
 (0)