From afc99dd310f5324446529cffa4844f6bd8316fd8 Mon Sep 17 00:00:00 2001 From: ryanhammonds Date: Thu, 29 Jul 2021 15:23:15 -0700 Subject: [PATCH 1/3] plot spectra accepts 2d arrays --- neurodsp/plts/spectral.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/neurodsp/plts/spectral.py b/neurodsp/plts/spectral.py index 25ff169b..3606da0c 100644 --- a/neurodsp/plts/spectral.py +++ b/neurodsp/plts/spectral.py @@ -18,9 +18,9 @@ def plot_power_spectra(freqs, powers, labels=None, colors=None, ax=None, **kwarg Parameters ---------- - freqs : 1d array or list of 1d array + freqs : 1d or 2d array Frequency vector. - powers : 1d array or list of 1d array + powers : 1d or 2d array Power values. labels : str or list of str, optional Labels for each time series. @@ -47,8 +47,7 @@ def plot_power_spectra(freqs, powers, labels=None, colors=None, ax=None, **kwarg ax = check_ax(ax, (6, 6)) - freqs = repeat(freqs) if isinstance(freqs, np.ndarray) else freqs - powers = [powers] if isinstance(powers, np.ndarray) else powers + freqs = repeat(freqs) if isinstance(freqs, np.ndarray) and freqs.ndim == 1 else freqs if labels is not None: labels = [labels] if not isinstance(labels, list) else labels From a63a6b88a9de446539756d40b2478668167c5ea7 Mon Sep 17 00:00:00 2001 From: ryanhammonds Date: Thu, 29 Jul 2021 15:40:54 -0700 Subject: [PATCH 2/3] fix 1d power case --- neurodsp/plts/spectral.py | 1 + 1 file changed, 1 insertion(+) diff --git a/neurodsp/plts/spectral.py b/neurodsp/plts/spectral.py index 3606da0c..1b557641 100644 --- a/neurodsp/plts/spectral.py +++ b/neurodsp/plts/spectral.py @@ -48,6 +48,7 @@ def plot_power_spectra(freqs, powers, labels=None, colors=None, ax=None, **kwarg ax = check_ax(ax, (6, 6)) freqs = repeat(freqs) if isinstance(freqs, np.ndarray) and freqs.ndim == 1 else freqs + powers = [powers] if isinstance(powers, np.ndarray) and powers.ndim == 1 else powers if labels is not None: labels = [labels] if not isinstance(labels, list) else labels From d081c27c5304377765f903df2bb2562f90f18026 Mon Sep 17 00:00:00 2001 From: ryanhammonds Date: Fri, 30 Jul 2021 13:52:37 -0700 Subject: [PATCH 3/3] docstring update --- neurodsp/plts/spectral.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neurodsp/plts/spectral.py b/neurodsp/plts/spectral.py index 1b557641..b7a7fe4e 100644 --- a/neurodsp/plts/spectral.py +++ b/neurodsp/plts/spectral.py @@ -18,9 +18,9 @@ def plot_power_spectra(freqs, powers, labels=None, colors=None, ax=None, **kwarg Parameters ---------- - freqs : 1d or 2d array + freqs : 1d or 2d array or list of 1d array Frequency vector. - powers : 1d or 2d array + powers : 1d or 2d array or list of 1d array Power values. labels : str or list of str, optional Labels for each time series.