Skip to content

Commit 4ef9b4e

Browse files
tomwhitejeromekelleher
authored andcommitted
Handle case of no compressors in get_compressor_config
1 parent fb26d23 commit 4ef9b4e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

bio2zarr/zarr_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ def get_compressor(array):
197197

198198
def get_compressor_config(array):
199199
compressor = get_compressor(array)
200+
if compressor is None:
201+
return None
200202
# numcodecs codecs (zarr format v2 path) expose get_config directly.
201203
if hasattr(compressor, "get_config"):
202204
return compressor.get_config()

tests/test_zarr_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,12 @@ class Stub:
549549
assert config["cname"] == "zstd"
550550
assert config["clevel"] == 4
551551

552+
def test_no_compressors(self):
553+
class Stub:
554+
compressors = ()
555+
556+
assert zarr_utils.get_compressor_config(Stub()) is None
557+
552558
def test_unsupported_type_raises(self):
553559
class FakeCodec:
554560
pass

0 commit comments

Comments
 (0)