Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_sharding(
[
codecs.transpose_codec("F"),
codecs.bytes_codec(),
codecs.blosc_codec(typesize=data.dtype.itemsize, cname="lz4"),
codecs.blosc_codec(cname="lz4"),
],
index_location=index_location,
)
Expand Down Expand Up @@ -516,7 +516,7 @@ def test_open_sharding(store: Store):
[
codecs.transpose_codec("F"),
codecs.bytes_codec(),
codecs.blosc_codec(typesize=4),
codecs.blosc_codec(),
],
)
],
Expand Down Expand Up @@ -675,7 +675,7 @@ def test_write_partial_sharded_chunks(store: Store):
chunk_shape=(10, 10),
codecs=[
codecs.bytes_codec(),
codecs.blosc_codec(typesize=data.dtype.itemsize),
codecs.blosc_codec(),
],
)
],
Expand Down
8 changes: 5 additions & 3 deletions zarrita/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ def from_metadata(
cls, codec_metadata: BloscCodecMetadata, array_metadata: CoreArrayMetadata
) -> BloscCodec:
configuration = codec_metadata.configuration
if configuration.typesize == 0:
if configuration.typesize is None:
configuration = evolve(
configuration, typesize=array_metadata.data_type.byte_count
)

# Prepare config_dict for the numcodecs.blosc.Blosc constructor
config_dict = asdict(codec_metadata.configuration)
config_dict.pop("typesize", None)
config_dict.pop("typesize")
map_shuffle_str_to_int = {"noshuffle": 0, "shuffle": 1, "bitshuffle": 2}
config_dict["shuffle"] = map_shuffle_str_to_int[config_dict["shuffle"]]
return cls(
Expand Down Expand Up @@ -545,7 +547,7 @@ def compute_encoded_size(self, input_byte_length: int) -> int:


def blosc_codec(
typesize: int,
typesize: Optional[int] = None,
cname: Literal["lz4", "lz4hc", "blosclz", "zstd", "snappy", "zlib"] = "zstd",
clevel: int = 5,
shuffle: Literal["noshuffle", "shuffle", "bitshuffle"] = "noshuffle",
Expand Down
2 changes: 1 addition & 1 deletion zarrita/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def encode_chunk_key(self, chunk_coords: ChunkCoords) -> str:

@frozen
class BloscCodecConfigurationMetadata:
typesize: int
typesize: Optional[int] = None
cname: Literal["lz4", "lz4hc", "blosclz", "zstd", "snappy", "zlib"] = "zstd"
clevel: int = 5
shuffle: BloscShuffle = "noshuffle"
Expand Down
Loading