Skip to content

Commit

Permalink
set default typesize=None
Browse files Browse the repository at this point in the history
  • Loading branch information
brokkoli71 committed Sep 28, 2024
1 parent eeebe24 commit 884150e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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 = 0,
typesize: int | None = 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 = 0
typesize: int | None = None
cname: Literal["lz4", "lz4hc", "blosclz", "zstd", "snappy", "zlib"] = "zstd"
clevel: int = 5
shuffle: BloscShuffle = "noshuffle"
Expand Down

0 comments on commit 884150e

Please sign in to comment.