X Tutup
Skip to content

BUG: Inconsistent handling of np.nan in np.timedelta64 arrays #30959

@riku-sakamoto

Description

@riku-sakamoto

Describe the issue:

np.nan is not allowed when creating np.timedelta64 arrays, but np.full allows it.
Would it be better to allow np.nan in np.timedelta64 arrays?

Reproduce the code example:

import numpy as np

# This code is allowed
np.full((3, 3), np.nan, dtype="m8[s]")

# This raise ValueError
np.array([np.nan], dtype="m8[s]")

Error message:

Python and NumPy Versions:

2.5.0.dev0+git20260306.34bb046

Runtime Environment:

No response

How does this issue affect you or how did you find it:

Through investigation of the effect of #29619 , I've found this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup