From 8e1187926a41700154316ba625e7f4a3901a66c4 Mon Sep 17 00:00:00 2001 From: "S.J. Guillot" <58807831+sjg2203@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:35:28 +0200 Subject: [PATCH 1/2] Updated the now deprecated Series.replace() to Series.cat.rename_categories() Signed-off-by: S.J. Guillot <58807831+sjg2203@users.noreply.github.com> --- yasa/hypno.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasa/hypno.py b/yasa/hypno.py index 980c11e..4789eb1 100644 --- a/yasa/hypno.py +++ b/yasa/hypno.py @@ -482,7 +482,7 @@ def as_int(self): Name: Stage, dtype: int16 """ # Return as int16 (-32768 to 32767) to reduce memory usage - return self.hypno.replace(self.mapping).astype(np.int16) + return self.hypno.cat.rename_categories(self.mapping).astype(np.int16) def consolidate_stages(self, new_n_stages): """Reduce the number of stages in a hypnogram to match actigraphy or wearables. From 553814afbdb7dd1aee7abff8d2e29549c5843753 Mon Sep 17 00:00:00 2001 From: "S.J. Guillot" <58807831+sjg2203@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:35:58 +0200 Subject: [PATCH 2/2] Updated freq_str in plot_spectrogram() as 's' of pd.Timedelta is now preferred over 'S' Signed-off-by: S.J. Guillot <58807831+sjg2203@users.noreply.github.com> --- yasa/plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yasa/plotting.py b/yasa/plotting.py index 927cff4..70fab24 100644 --- a/yasa/plotting.py +++ b/yasa/plotting.py @@ -331,7 +331,7 @@ def plot_spectrogram( if hypno is not None: # Convert sampling frequency to pandas timefrequency string (e.g., "30s") - freq_str = pd.tseries.frequencies.to_offset(pd.Timedelta(1 / sf, "S")).freqstr + freq_str = pd.tseries.frequencies.to_offset(pd.Timedelta(1 / sf, "s")).freqstr # Create Hypnogram instance for plotting hyp = Hypnogram(hypno_int_to_str(hypno), freq=freq_str) hypnoplot_kwargs = dict(lw=1.5, fill_color=None)