|
26 | 26 | FiltersParam, |
27 | 27 | _get_default_chunk_encoding_v2, |
28 | 28 | _get_default_chunk_encoding_v3, |
| 29 | + _parse_chunk_encoding_v2, |
29 | 30 | _parse_chunk_encoding_v3, |
30 | 31 | chunks_initialized, |
31 | 32 | create_array, |
@@ -1002,43 +1003,26 @@ async def test_create_array_no_filters_compressors( |
1002 | 1003 |
|
1003 | 1004 |
|
1004 | 1005 | @pytest.mark.parametrize("store", ["memory"], indirect=True) |
| 1006 | +@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"]) |
1005 | 1007 | @pytest.mark.parametrize( |
1006 | 1008 | "compressors", |
1007 | 1009 | [ |
1008 | 1010 | "auto", |
| 1011 | + None, |
| 1012 | + (), |
1009 | 1013 | (ZstdCodec(level=3),), |
1010 | 1014 | (ZstdCodec(level=3), GzipCodec(level=0)), |
1011 | 1015 | ZstdCodec(level=3), |
1012 | 1016 | {"name": "zstd", "configuration": {"level": 3}}, |
1013 | 1017 | ({"name": "zstd", "configuration": {"level": 3}},), |
1014 | 1018 | ], |
1015 | 1019 | ) |
1016 | | -async def test_create_array_v3_compressors( |
1017 | | - store: MemoryStore, compressors: CompressorsParam |
1018 | | -) -> None: |
1019 | | - """ |
1020 | | - Test various possibilities for the compressors parameter to create_array |
1021 | | - """ |
1022 | | - dtype = "uint8" |
1023 | | - arr = await create_array( |
1024 | | - store=store, |
1025 | | - dtype=dtype, |
1026 | | - shape=(10,), |
1027 | | - zarr_format=3, |
1028 | | - compressors=compressors, |
1029 | | - ) |
1030 | | - _, _, bb_codecs_expected = _parse_chunk_encoding_v3( |
1031 | | - filters=(), compressors=compressors, dtype=np.dtype(dtype) |
1032 | | - ) |
1033 | | - # TODO: find a better way to get the compressors from the array. |
1034 | | - assert arr.codec_pipeline.bytes_bytes_codecs == bb_codecs_expected # type: ignore[attr-defined] |
1035 | | - |
1036 | | - |
1037 | | -@pytest.mark.parametrize("store", ["memory"], indirect=True) |
1038 | 1020 | @pytest.mark.parametrize( |
1039 | 1021 | "filters", |
1040 | 1022 | [ |
1041 | 1023 | "auto", |
| 1024 | + None, |
| 1025 | + (), |
1042 | 1026 | ( |
1043 | 1027 | TransposeCodec( |
1044 | 1028 | order=[ |
@@ -1067,23 +1051,58 @@ async def test_create_array_v3_compressors( |
1067 | 1051 | ({"name": "transpose", "configuration": {"order": [0]}},), |
1068 | 1052 | ], |
1069 | 1053 | ) |
1070 | | -async def test_create_array_v3_filters(store: MemoryStore, filters: FiltersParam) -> None: |
| 1054 | +async def test_create_array_v3_chunk_encoding( |
| 1055 | + store: MemoryStore, compressors: CompressorsParam, filters: FiltersParam, dtype: str |
| 1056 | +) -> None: |
1071 | 1057 | """ |
1072 | | - Test various possibilities for the filters parameter to create_array |
| 1058 | + Test various possibilities for the compressors and filters parameter to create_array |
1073 | 1059 | """ |
1074 | | - dtype = "uint8" |
1075 | 1060 | arr = await create_array( |
1076 | 1061 | store=store, |
1077 | 1062 | dtype=dtype, |
1078 | 1063 | shape=(10,), |
1079 | 1064 | zarr_format=3, |
1080 | 1065 | filters=filters, |
| 1066 | + compressors=compressors, |
1081 | 1067 | ) |
1082 | | - aa_codecs_expected, _, _ = _parse_chunk_encoding_v3( |
1083 | | - filters=filters, compressors=(), dtype=np.dtype(dtype) |
| 1068 | + aa_codecs_expected, _, bb_codecs_expected = _parse_chunk_encoding_v3( |
| 1069 | + filters=filters, compressors=compressors, dtype=np.dtype(dtype) |
1084 | 1070 | ) |
1085 | | - # TODO: find a better way to get the filters from the array. |
| 1071 | + # TODO: find a better way to get the filters / compressors from the array. |
1086 | 1072 | assert arr.codec_pipeline.array_array_codecs == aa_codecs_expected # type: ignore[attr-defined] |
| 1073 | + assert arr.codec_pipeline.bytes_bytes_codecs == bb_codecs_expected # type: ignore[attr-defined] |
| 1074 | + |
| 1075 | + |
| 1076 | +@pytest.mark.parametrize("store", ["memory"], indirect=True) |
| 1077 | +@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"]) |
| 1078 | +@pytest.mark.parametrize( |
| 1079 | + "compressors", |
| 1080 | + [ |
| 1081 | + "auto", |
| 1082 | + None, |
| 1083 | + numcodecs.Zstd(level=3), |
| 1084 | + ], |
| 1085 | +) |
| 1086 | +@pytest.mark.parametrize( |
| 1087 | + "filters", ["auto", None, numcodecs.GZip(level=1), (numcodecs.GZip(level=1),)] |
| 1088 | +) |
| 1089 | +async def test_create_array_v2_chunk_encoding( |
| 1090 | + store: MemoryStore, compressors: CompressorsParam, filters: FiltersParam, dtype: str |
| 1091 | +) -> None: |
| 1092 | + arr = await create_array( |
| 1093 | + store=store, |
| 1094 | + dtype=dtype, |
| 1095 | + shape=(10,), |
| 1096 | + zarr_format=2, |
| 1097 | + compressors=compressors, |
| 1098 | + filters=filters, |
| 1099 | + ) |
| 1100 | + filters_expected, compressor_expected = _parse_chunk_encoding_v2( |
| 1101 | + filters=filters, compressor=compressors, dtype=np.dtype(dtype) |
| 1102 | + ) |
| 1103 | + # TODO: find a better way to get the filters/compressor from the array. |
| 1104 | + assert arr.metadata.compressor == compressor_expected # type: ignore[union-attr] |
| 1105 | + assert arr.metadata.filters == filters_expected # type: ignore[union-attr] |
1087 | 1106 |
|
1088 | 1107 |
|
1089 | 1108 | @pytest.mark.parametrize("store", ["memory"], indirect=True) |
|
0 commit comments