Skip to content

BUG: Creating an array with multiple NaTs can result in loss of NaTness #29497

@WarrenWeckesser

Description

@WarrenWeckesser

Describe the issue:

When two or more timedelta64 NaT instances with different units are used to create an array, it is possible for one of them to become a regular timedelta64 in the array.

Reproduce the code example:

In [48]: nat = np.timedelta64('nat')

In [49]: nat_s = np.timedelta64('nat', 's')

In [50]: nat_ms = np.timedelta64('nat', 'ms')

In [51]: a = np.array([nat, nat_s, nat_ms])

In [52]: a
Out[52]: array(['NaT',     0, 'NaT'], dtype='timedelta64[ms]')

In [53]: a[1]
Out[53]: np.timedelta64(0,'ms')  # This should be a NaT.

Python and NumPy Versions:

2.4.0.dev0+git20250801.9da497f
3.13.5 (main, Jul 15 2025, 14:50:34) [GCC 11.4.0]

Runtime Environment:

[{'numpy_version': '2.4.0.dev0+git20250801.9da497f',
'python': '3.13.5 (main, Jul 15 2025, 14:50:34) [GCC 11.4.0]',
'uname': uname_result(system='Linux', node='pop-os', release='6.12.10-76061203-generic', version='#202412060638175139074222.04~79b9668 SMP PREEMPT_DYNAMIC Tue J', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}},
{'architecture': 'Zen',
'filepath': '/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so',
'internal_api': 'openblas',
'num_threads': 24,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.20'}]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions