From bb0047adb19bec552727557f4192cf4adb59e351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Thu, 23 Apr 2026 09:33:06 +0200 Subject: [PATCH 1/2] BUG: avoid a deprecation warning from numpy 2.5 (calling `datetime64('NaT')` without a unit is deprecated) --- lib/matplotlib/dates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index f5f0918dcc13..3876d42c7923 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -325,7 +325,7 @@ def _dt64_to_ordinalf(d): dt += extra.astype(np.float64) / 1.0e9 dt = dt / SEC_PER_DAY - NaT_int = np.datetime64('NaT').astype(np.int64) + NaT_int = np.datetime64('NaT', 's').astype(np.int64) d_int = d.astype(np.int64) dt[d_int == NaT_int] = np.nan return dt From 09ec3674a1c803622fdd57466c9cd4fa661a0c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Thu, 23 Apr 2026 16:54:00 +0200 Subject: [PATCH 2/2] Update dates.py Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> --- lib/matplotlib/dates.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 3876d42c7923..77c803cde6e5 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -325,9 +325,7 @@ def _dt64_to_ordinalf(d): dt += extra.astype(np.float64) / 1.0e9 dt = dt / SEC_PER_DAY - NaT_int = np.datetime64('NaT', 's').astype(np.int64) - d_int = d.astype(np.int64) - dt[d_int == NaT_int] = np.nan + dt[np.isnat(d)] = np.nan return dt