Re: Deprecating unitless timedelta/datetime
Lucas Colley via NumPy-Discussion <[email protected]> Sun, 29 Mar 2026 12:49:23 +0000
| Newsgroups | gmane.comp.python.numeric.general |
|---|---|
| Message-ID | <MA2P292MB0180CC58F37A82C82391CF80A255A@MA2P292MB0180.ESPP292.PROD.OUTLOOK.COM> |
--===============7717026885315560589==
Content-Language: en-GB
Content-Type: multipart/alternative;
boundary="_000_MA2P292MB0180CC58F37A82C82391CF80A255AMA2P292MB0180ESPP_"
--_000_MA2P292MB0180CC58F37A82C82391CF80A255AMA2P292MB0180ESPP_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi Sebastian,
One thing this breaks is the following, which is part of SciPy's testsuite:
```
@pytest.mark.parametrize("dtype", np.typecodes['All'])
...
np.eye(2, dtype=3Ddtype)
```
Is there a recommended alternative for downstream libraries who want to tes=
t with ~all dtypes easily, but not all dtypes?
https://github.com/scipy/scipy/actions/runs/23708171067/job/69063440694?pr=
=3D24921
Cheers,
Lucas
________________________________
From: Sebastian Berg <[email protected]>
Sent: 29 March 2026 11:37
To: Discussion of Numerical Python <[email protected]>
Subject: [Numpy-discussion] Deprecating unitless timedelta/datetime
Hi all,
I just merged a PR: https://github.com/numpy/numpy/pull/29619
to deprecate unitless timdeldta/datetime64. This is a step in a direction
that should be e.g. very helpful for pandas to make timedelta/datetimes
less weird.
That said, we didn't touch this for a long time, because it is also
very hard to really understand how and if users might be impacted.
So if you notice this, or maybe even think you may be mixing timedeltas
with normal integers/floats a lot you may want to try this branch.
This is a `DeprecationWarning`, so it shouldn't out-right break code in
production.
Note that there are also specific things we could try to make more
gentle, even something niche like specifically allowing:
`timdelta_arr =3D=3D 0` (although `timedelta_arr.astype(bool)` should be a
plausible replacement as well, I think).
Or generally keep allowing `timedelta_arr + integer_arr`, etc. which,
with this PR, I believe should give a warning.
Cheers,
Sebastian
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]
--_000_MA2P292MB0180CC58F37A82C82391CF80A255AMA2P292MB0180ESPP_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
Hi Sebastian,</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
One thing this breaks is the following, which is part of SciPy's testsuite:=
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
```</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
@pytest.mark.parametrize("dtype", np.typecodes['All'])</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
...</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
np.eye(2, dtype=3Ddtype)</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
```</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
Is there a recommended alternative for downstream libraries who want to tes=
t with ~all dtypes easily, but not
<i>all</i> dtypes?</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<a href=3D"https://github.com/scipy/scipy/actions/runs/23708171067/job/6906=
3440694?pr=3D24921">https://github.com/scipy/scipy/actions/runs/23708171067=
/job/69063440694?pr=3D24921</a></div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
<br>
</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
Cheers,</div>
<div class=3D"elementToProof" style=3D"font-family: Aptos, Aptos_EmbeddedFo=
nt, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; c=
olor: rgb(0, 0, 0);">
Lucas</div>
<div id=3D"appendonsend"></div>
<hr style=3D"display:inline-block;width:98%" tabindex=3D"-1">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" st=
yle=3D"font-size:11pt" color=3D"#000000"><b>From:</b> Sebastian Berg <se=
[email protected]><br>
<b>Sent:</b> 29 March 2026 11:37<br>
<b>To:</b> Discussion of Numerical Python <[email protected]&g=
t;<br>
<b>Subject:</b> [Numpy-discussion] Deprecating unitless timedelta/datetime<=
/font>
<div> </div>
</div>
<div class=3D"BodyFragment"><font size=3D"2"><span style=3D"font-size:11pt;=
">
<div class=3D"PlainText">Hi all,<br>
<br>
I just merged a PR: <a href=3D"https://github.com/numpy/numpy/pull/296=
19">https://github.com/numpy/numpy/pull/29619</a><br>
to deprecate unitless timdeldta/datetime64. This is a step in a direction<b=
r>
that should be e.g. very helpful for pandas to make timedelta/datetimes<br>
less weird.<br>
<br>
That said, we didn't touch this for a long time, because it is also<br>
very hard to really understand how and if users might be impacted.<br>
So if you notice this, or maybe even think you may be mixing timedeltas<br>
with normal integers/floats a lot you may want to try this branch.<br>
<br>
This is a `DeprecationWarning`, so it shouldn't out-right break code in<br>
production.<br>
<br>
Note that there are also specific things we could try to make more<br>
gentle, even something niche like specifically allowing:<br>
`timdelta_arr =3D=3D 0` (although `timedelta_arr.astype(bool)` should be a<=
br>
plausible replacement as well, I think).<br>
Or generally keep allowing `timedelta_arr + integer_arr`, etc. which,<br>
with this PR, I believe should give a warning.<br>
<br>
Cheers,<br>
<br>
Sebastian<br>
_______________________________________________<br>
NumPy-Discussion mailing list -- [email protected]<br>
To unsubscribe send an email to [email protected]<br>
<a href=3D"https://mail.python.org/mailman3//lists/numpy-discussion.python.=
org">https://mail.python.org/mailman3//lists/numpy-discussion.python.org</a=
><br>
Member address: [email protected]<br>
</div>
</span></font></div>
</body>
</html>
--_000_MA2P292MB0180CC58F37A82C82391CF80A255AMA2P292MB0180ESPP_--
--===============7717026885315560589==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]
--===============7717026885315560589==--