Skip to content

Implicit unit in numpy timedelta is deprecated #3918

Description

@jl-wynen

NumPy now raises a deprecation warning when constructing a timedelta without a unit:

>>> np.timedelta64(15)
<python-input-5>:1: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
np.timedelta64(15)

This trips up our tests in https://github.com/scipp/scipp/actions/runs/28449665963/job/84308178323 where we use

sc.arange(
        't',
        np.datetime64('2022-08-02T11:18'),
        np.datetime64('2022-08-02T11:52'),
        15
    )

This can be fixed by passing the step size as np.timedelta64(15, 'm').

Do we want to update arange to automatically deduce a unit for the step size or do we go with NumPy's new behaviour?

Activity

  1. added
    dependenciesPull requests that update a dependency file
    pythonPull requests that update Python code
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency filepythonPull requests that update Python code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions