Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] 2d Array Plotting #246

Merged
merged 3 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions neurodsp/plts/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def plot_time_series(times, sigs, labels=None, colors=None, ax=None, **kwargs):

Parameters
----------
times : 1d array or list of 1d array
times : 1d or 2d array, or list of 1d array
Time definition(s) for the time series to be plotted.
sigs : 1d array or list of 1d array
sigs : 1d or 2d array, or list of 1d array
Time series to plot.
labels : list of str, optional
Labels for each time series.
Expand All @@ -47,8 +47,8 @@ def plot_time_series(times, sigs, labels=None, colors=None, ax=None, **kwargs):

ax = check_ax(ax, (15, 3))

times = repeat(times) if isinstance(times, np.ndarray) else times
ryanhammonds marked this conversation as resolved.
Show resolved Hide resolved
sigs = [sigs] if isinstance(sigs, np.ndarray) else sigs
ryanhammonds marked this conversation as resolved.
Show resolved Hide resolved
times = repeat(times) if (isinstance(times, np.ndarray) and times.ndim == 1) else times
sigs = [sigs] if (isinstance(sigs, np.ndarray) and sigs.ndim == 1) else sigs

if labels is not None:
labels = [labels] if not isinstance(labels, list) else labels
Expand All @@ -74,9 +74,9 @@ def plot_instantaneous_measure(times, sigs, measure='phase', ax=None, **kwargs):

Parameters
----------
times : 1d array or list of 1d array
times : 1d or 2d array, or list of 1d array
Time definition(s) for the time series to be plotted.
sigs : 1d array or list of 1d array
sigs : 1d or 2d array, or list of 1d array
Time series to plot.
measure : {'phase', 'amplitude', 'frequency'}
Which kind of measure is being plotted.
Expand Down
6 changes: 6 additions & 0 deletions neurodsp/tests/plts/test_time_series.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test time series plots."""

from pytest import raises
import numpy as np

from neurodsp.tests.settings import TEST_PLOTS_PATH
from neurodsp.tests.tutils import plot_test
Expand All @@ -23,6 +24,11 @@ def test_plot_time_series(tsig):
colors=['k', 'r'], save_fig=True, file_name='test_plot_time_series.png',
file_path=TEST_PLOTS_PATH)

# Test 2D arrays
times_2d = np.vstack((times, times))
tsig_2d = np.vstack((tsig, tsig))
plot_time_series(times_2d, tsig_2d)

@plot_test
def test_plot_instantaneous_measure(tsig):

Expand Down