From f1a931e7ec64e28e9777599e2813eebd92727033 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Sun, 4 Feb 2024 14:17:38 +0100 Subject: [PATCH] MNT: filter irrelevant warning about silent downcasting --- fastf1/core.py | 27 ++++++++++++++++++++++++--- pytest.ini | 2 -- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/fastf1/core.py b/fastf1/core.py index 9da299703..f7378ecdc 100644 --- a/fastf1/core.py +++ b/fastf1/core.py @@ -525,8 +525,19 @@ def merge_channels( .interpolate(method=method, **interp_kwargs) elif sig_type == 'discrete': - res = merged.loc[:, ch].resample(frq, origin=ref_date) \ - .ffill().ffill().bfill() + with warnings.catch_warnings(): + # deprecated since pandas 2.2.0; don't opt in to new + # behaviour as that would silently change behaviour for + # user code; irrelevant here, therefore just filter + warnings.filterwarnings( + "ignore", + "Downcasting object dtype arrays on .fillna, " + ".ffill, .bfill is deprecated", + FutureWarning + ) + res = merged.loc[:, ch] \ + .resample(frq, origin=ref_date) \ + .ffill().ffill().bfill() # first ffill is a method of the resampler object and will # ONLY ffill values created during resampling but not # already existing NaN values. NaN values already existed @@ -659,7 +670,17 @@ def fill_missing(self): .interpolate(method=method, **interp_kwargs) elif sig_type == 'discrete': - ret.loc[:, ch] = ret.loc[:, ch].ffill().ffill().bfill() + with warnings.catch_warnings(): + # deprecated since pandas 2.2.0; don't opt in to new + # behaviour as that would silently change behaviour for + # user code; irrelevant here, therefore just filter + warnings.filterwarnings( + "ignore", + "Downcasting object dtype arrays on .fillna, " + ".ffill, .bfill is deprecated", + FutureWarning + ) + ret.loc[:, ch] = ret.loc[:, ch].ffill().ffill().bfill() # first ffill is a method of the resampler object and will # ONLY ffill values created during resampling but not already # existing NaN values. NaN values already existed because of diff --git a/pytest.ini b/pytest.ini index 5ca47fdf9..204d82b4a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -45,5 +45,3 @@ filterwarnings = ignore:(?s).*Pyarrow will become a required dependency of pandas.*:DeprecationWarning # TODO: temp, should be resolved with pandas 2.2.1 ignore:Passing a (Single)?BlockManager to.*:DeprecationWarning - # TODO: temp, needs to be actually fixed before pandas 3.0.0 - ignore:Downcasting object dtype arrays.*:FutureWarning