From 70839853b9d7689b69a6f331a57b521d130882c3 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 22 Apr 2026 14:55:14 +0200 Subject: [PATCH 1/3] fix: declare a unit when creating NaT datetime --- src/zarr/core/dtype/npy/time.py | 2 +- tests/test_dtype/test_npy/test_time.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zarr/core/dtype/npy/time.py b/src/zarr/core/dtype/npy/time.py index c4495e167c..6a864dc889 100644 --- a/src/zarr/core/dtype/npy/time.py +++ b/src/zarr/core/dtype/npy/time.py @@ -851,7 +851,7 @@ def default_scalar(self) -> np.datetime64: The default scalar value, which is a 'Not-a-Time' (NaT) value """ - return np.datetime64("NaT") + return np.datetime64("NaT", self.unit) def from_json_scalar(self, data: JSON, *, zarr_format: ZarrFormat) -> np.datetime64: """ diff --git a/tests/test_dtype/test_npy/test_time.py b/tests/test_dtype/test_npy/test_time.py index 1b1f428e40..67ba3bd130 100644 --- a/tests/test_dtype/test_npy/test_time.py +++ b/tests/test_dtype/test_npy/test_time.py @@ -66,7 +66,7 @@ class TestDateTime64(_TestTimeBase): cast_value_params = ( (DateTime64(unit="Y", scale_factor=1), "1", np.datetime64("1", "Y")), (DateTime64(unit="s", scale_factor=1), "2005-02-25", np.datetime64("2005-02-25", "s")), - (DateTime64(unit="ns", scale_factor=1), "NaT", np.datetime64("NaT")), + (DateTime64(unit="ns", scale_factor=1), "NaT", np.datetime64("NaT", "ns")), ) invalid_scalar_params = ( (DateTime64(unit="Y", scale_factor=1), 1.3), From 1e9d0a6ef2b0c07709bf4c44437a696a0871fd64 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 22 Apr 2026 14:55:47 +0200 Subject: [PATCH 2/3] fix: use latest version of ml_dtypes in example script --- examples/custom_dtype/custom_dtype.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/custom_dtype/custom_dtype.py b/examples/custom_dtype/custom_dtype.py index eee510349b..a13283a681 100644 --- a/examples/custom_dtype/custom_dtype.py +++ b/examples/custom_dtype/custom_dtype.py @@ -2,7 +2,7 @@ # requires-python = ">=3.12" # dependencies = [ # "zarr @ git+https://github.com/zarr-developers/zarr-python.git@main", -# "ml_dtypes==0.5.1", +# "ml_dtypes==0.5.4", # "pytest==8.4.1" # ] # /// From e41a98f140ff6d88785e9c273500f9c29988730f Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 22 Apr 2026 15:01:30 +0200 Subject: [PATCH 3/3] docs: changelog --- changes/3920.bugfix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/3920.bugfix.md diff --git a/changes/3920.bugfix.md b/changes/3920.bugfix.md new file mode 100644 index 0000000000..289d12970c --- /dev/null +++ b/changes/3920.bugfix.md @@ -0,0 +1 @@ +Use the unit associated with the `Datetime64` data type when creating the default `Nat` scalar value. \ No newline at end of file