Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/3920.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the unit associated with the `Datetime64` data type when creating the default `Nat` scalar value.
2 changes: 1 addition & 1 deletion examples/custom_dtype/custom_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
# ]
# ///
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/dtype/npy/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dtype/test_npy/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Loading