From 1f677efd1d11995a4b90efbc5194f763c6bf901e Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Thu, 13 Apr 2023 12:00:14 -0500 Subject: [PATCH 1/2] avoid pandas FutureWarning --- mne/time_frequency/tests/test_spectrum.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mne/time_frequency/tests/test_spectrum.py b/mne/time_frequency/tests/test_spectrum.py index 28a4244b789..8ae49ee9853 100644 --- a/mne/time_frequency/tests/test_spectrum.py +++ b/mne/time_frequency/tests/test_spectrum.py @@ -176,8 +176,8 @@ def test_unaggregated_spectrum_to_data_frame(raw, long_format, method, output): # sorting at the agg step *sigh* _inplace(orig_df, 'sort_values', by=grouping_cols, ignore_index=True) # aggregate - gb = df.drop(columns=drop_cols).groupby( - grouping_cols, as_index=False, observed=False) + df = df.drop(columns=drop_cols) + gb = df.groupby(grouping_cols, as_index=False, observed=False) if method == 'welch': if output == 'complex': def _fun(x): @@ -186,6 +186,7 @@ def _fun(x): _fun = np.nanmean agg_df = gb.aggregate(_fun) else: + gb = gb[df.columns] # https://github.com/pandas-dev/pandas/pull/52477 agg_df = gb.apply(_agg_helper, spectrum._mt_weights, grouping_cols) # even with check_categorical=False, we know that the *data* matches; # what may differ is the order of the "levels" in the *metadata* for the From c7caf5a09767e6f308702e1961e72d8a575fa1c2 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Thu, 13 Apr 2023 12:11:20 -0500 Subject: [PATCH 2/2] remove filter --- mne/time_frequency/tests/test_spectrum.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mne/time_frequency/tests/test_spectrum.py b/mne/time_frequency/tests/test_spectrum.py index 8ae49ee9853..14b68890753 100644 --- a/mne/time_frequency/tests/test_spectrum.py +++ b/mne/time_frequency/tests/test_spectrum.py @@ -137,8 +137,6 @@ def _agg_helper(df, weights, group_cols): return Series(_df) -# TODO: Fix this warning -@pytest.mark.filterwarnings("ignore:.*columns to operate on.*:FutureWarning") @pytest.mark.parametrize('long_format', (False, True)) @pytest.mark.parametrize('method, output', [ ('welch', 'complex'),