You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d7686f6
Browse filesBrowse the repository at this point in the historyBrowse files
fix(dtype): preserve scaled generic time units and normalize the μs alias (zarr-developers#4342)
* fix(dtype): preserve scaled generic time units and normalize the μs alias
`DateTime64` and `TimeDelta64` read unit and scale from the dtype object
rather than `dtype.name`, which drops a generic unit's scale. V2 metadata
writes an explicit `[Ngeneric]` suffix; the constructor stores `μs` as `us`.
NumPy allocation drops a generic time dtype's scale and byte order, and
`astype` between generic time dtypes ignores the target. The CPU buffer
restores the dtype with a view after allocation and converts endian-only
casts through the integer counts. Integer fill values for generic datetimes
decode through `datetime_from_int`, and structured defaults build a zero
count for generic datetime fields.
Assisted-by: ClaudeCode:claude-opus-5-5
* test(dtype): cover the time unit grid through the dtype test harness
Generate the valid native dtypes and V2/V3 JSON for `DateTime64` and
`TimeDelta64` from every unit, scales 1, 2 and 2**31 - 1, and both byte
orders, instead of a separate round-trip test that repeated the harness's
native and JSON round trips.
Assisted-by: ClaudeCode:claude-opus-5-5
* fix(dtype): keep the scale factor on NaT time scalars
`DateTime64.default_scalar`, `TimeDelta64.default_scalar`, and the NaT
branch of `TimeDelta64.cast_scalar` built NaT in the bare unit, dropping
the scale factor. On NumPy < 2.2, casting a timedelta NaT between scales
yields a count instead of NaT, so missing chunks of a `m8[2us]` array
read back as 2**62 - 1 instead of NaT.
Assisted-by: ClaudeCode:claude-opus-5-5
* docs(changelog): note the scaled NaT fill fix
Assisted-by: ClaudeCode:claude-opus-5-5
`DateTime64` and `TimeDelta64` normalize `μs` to `us` and preserve generic-unit scale factors when converting native NumPy dtypes and serializing V2/V3 metadata. V2 writes an explicit suffix such as `[2generic]` to avoid the scale loss in NumPy's `dtype.str` and `dtype.name`. Generic temporal arrays also preserve dtype parameters during CPU buffer allocation and correctly convert byte order; generic datetime fill values can be read back, including in structured fields. The default NaT fill value now carries the scale factor, so missing chunks of a scaled timedelta array such as `m8[2us]` read back as NaT on NumPy < 2.2 instead of an arbitrary count.
0 commit comments