Skip to content

Commit 96e013b

Browse files
committed
test: add test of None backwards compat
1 parent 61a1d01 commit 96e013b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_array.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,28 @@ def test_default_fill_value(dtype: ZDType[Any, Any], store: Store) -> None:
10121012
else:
10131013
assert a.fill_value == dtype.default_scalar()
10141014

1015+
@staticmethod
1016+
# @pytest.mark.parametrize("zarr_format", [2, 3])
1017+
@pytest.mark.parametrize("dtype", zdtype_examples)
1018+
@pytest.mark.filterwarnings("ignore::zarr.core.dtype.common.UnstableSpecificationWarning")
1019+
def test_default_fill_value_None(
1020+
dtype: ZDType[Any, Any], store: Store, zarr_format: ZarrFormat
1021+
) -> None:
1022+
"""
1023+
Test that the fill value of an array is set to the default value for an explicit None arguement for
1024+
Zarr Format 3, and to null for Zarr Format 2
1025+
"""
1026+
a = zarr.create_array(
1027+
store, shape=(5,), chunks=(5,), dtype=dtype, fill_value=None, zarr_format=zarr_format
1028+
)
1029+
if zarr_format == 3:
1030+
if isinstance(dtype, DateTime64 | TimeDelta64) and np.isnat(a.fill_value):
1031+
assert np.isnat(dtype.default_scalar())
1032+
else:
1033+
assert a.fill_value == dtype.default_scalar()
1034+
elif zarr_format == 2:
1035+
assert a.fill_value is None
1036+
10151037
@staticmethod
10161038
@pytest.mark.filterwarnings("ignore::zarr.core.dtype.common.UnstableSpecificationWarning")
10171039
@pytest.mark.parametrize("dtype", zdtype_examples)

0 commit comments

Comments
 (0)