<commit_before>"""Plotting functions for neurodsp.rhythm."""

from neurodsp.plts.style import style_plot
from neurodsp.plts.utils import check_ax, savefig

###################################################################################################
###################################################################################################

@savefig
@style_plot
def plot_swm_pattern(pattern, ax=None, **kwargs):
    """Plot the resulting pattern from a sliding window matching analysis.

    Parameters
    ----------
    pattern : 1d array
        The resulting average pattern from applying sliding window matching.
    ax : matplotlib.Axes, optional
        Figure axes upon which to plot.
    **kwargs
        Keyword arguments for customizing the plot.

    Examples
    --------
    Plot the average pattern from a sliding window matching analysis:

    >>> from neurodsp.sim import sim_combined
    >>> from neurodsp.rhythm import sliding_window_matching
    >>> sig = sim_combined(n_seconds=10, fs=500,
    ...                    components={'sim_powerlaw': {'f_range': (2, None)},
    ...                                'sim_bursty_oscillation': {'freq': 20,
    ...                                                           'enter_burst': .25,
    ...                                                           'leave_burst': .25}})
    >>> avg_window, _, _ = sliding_window_matching(sig, fs=500, win_len=0.05, win_spacing=0.5)
    >>> plot_swm_pattern(avg_window)
    """

    ax = check_ax(ax, (4, 4))

    ax.plot(pattern, 'k')

    ax.set_title('Average Pattern')
    ax.set_xlabel('Time (samples)')
    ax.set_ylabel('Voltage (a.u.)')

<commit_msg>fix doctest for plotting SWM<commit_after>"""Plotting functions for neurodsp.rhythm."""

from neurodsp.plts.style import style_plot
from neurodsp.plts.utils import check_ax, savefig

###################################################################################################
###################################################################################################

@savefig
@style_plot
def plot_swm_pattern(pattern, ax=None, **kwargs):
    """Plot the resulting pattern from a sliding window matching analysis.

    Parameters
    ----------
    pattern : 1d array
        The resulting average pattern from applying sliding window matching.
    ax : matplotlib.Axes, optional
        Figure axes upon which to plot.
    **kwargs
        Keyword arguments for customizing the plot.

    Examples
    --------
    Plot the average pattern from a sliding window matching analysis:

    >>> import numpy as np
    >>> from neurodsp.sim import sim_combined
    >>> from neurodsp.rhythm import sliding_window_matching
    >>> sig = sim_combined(n_seconds=10, fs=500,
    ...                    components={'sim_powerlaw': {'f_range': (2, None)},
    ...                                'sim_bursty_oscillation': {'freq': 20,
    ...                                                           'enter_burst': .25,
    ...                                                           'leave_burst': .25}})
    >>> windows, _ = sliding_window_matching(sig, fs=500, win_len=0.05, win_spacing=0.5)
    >>> avg_window = np.mean(windows)
    >>> plot_swm_pattern(avg_window)
    """

    ax = check_ax(ax, (4, 4))

    ax.plot(pattern, 'k')

    ax.set_title('Average Pattern')
    ax.set_xlabel('Time (samples)')
    ax.set_ylabel('Voltage (a.u.)')


{'fraction_non_alphanumeric': 0.22244897959183674, 'fraction_numerical': 0.013411078717201166, 'mean_word_length': 2.5010204081632654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6476041', 'n_tokens_mistral': 948, 'n_tokens_neox': 872, 'n_words': 228}