<commit_before># -*- coding: utf-8 -*-

"""Test waveform plotting."""

#------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------

import numpy as np
from vispy import app

from ...utils.logging import set_level
from ..waveforms import Waveforms, WaveformView
from .._color import _random_colors
from ...datasets.mock import (artificial_waveforms, artificial_masks,
                              artificial_spike_clusters)
from ...electrode.mea import staggered_positions
from ...utils.array import _normalize
from ...utils.testing import show_test


#------------------------------------------------------------------------------
# Fixtures
#------------------------------------------------------------------------------

def setup():
    set_level('debug')


def teardown():
    pass


#------------------------------------------------------------------------------
# Tests
#------------------------------------------------------------------------------


def _test_waveforms(n_spikes=None, n_clusters=None):
    n_channels = 32
    n_samples = 40

    channel_positions = staggered_positions(n_channels)
    channel_positions = _normalize(channel_positions)

    waveforms = artificial_waveforms(n_spikes, n_samples,
                                     n_channels).astype(np.float32)
    masks = artificial_masks(n_spikes, n_channels).astype(np.float32)
    spike_clusters = artificial_spike_clusters(n_spikes, n_clusters)

    cluster_colors = _random_colors(n_clusters).astype(np.float32)
    cluster_metadata = {cluster: {'color': color}
                        for cluster, color in enumerate(cluster_colors)}

    c = WaveformView()
    c.visual.waveforms = waveforms
    c.visual.masks = masks
    c.visual.spike_clusters = spike_clusters
    c.visual.cluster_metadata = cluster_metadata
    c.visual.channel_positions = channel_positions

    show_test(c)
<commit_msg>Fixed test bug.<commit_after># -*- coding: utf-8 -*-

"""Test waveform plotting."""

#------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------

import numpy as np
from vispy import app

from ...cluster.manual.cluster_metadata import ClusterMetadata
from ...utils.logging import set_level
from ..waveforms import Waveforms, WaveformView
from .._color import _random_colors
from ...datasets.mock import (artificial_waveforms, artificial_masks,
                              artificial_spike_clusters)
from ...electrode.mea import staggered_positions
from ...utils.array import _normalize
from ...utils.testing import show_test


#------------------------------------------------------------------------------
# Fixtures
#------------------------------------------------------------------------------

def setup():
    set_level('debug')


def teardown():
    pass


#------------------------------------------------------------------------------
# Tests
#------------------------------------------------------------------------------


def _test_waveforms(n_spikes=None, n_clusters=None):
    n_channels = 32
    n_samples = 40

    channel_positions = staggered_positions(n_channels)
    channel_positions = _normalize(channel_positions)

    waveforms = artificial_waveforms(n_spikes, n_samples,
                                     n_channels).astype(np.float32)
    masks = artificial_masks(n_spikes, n_channels).astype(np.float32)
    spike_clusters = artificial_spike_clusters(n_spikes, n_clusters)

    cluster_colors = _random_colors(n_clusters).astype(np.float32)
    metadata = {cluster: {'color': color}
                for cluster, color in enumerate(cluster_colors)}
    cluster_metadata = ClusterMetadata(metadata)

    c = WaveformView()
    c.visual.waveforms = waveforms
    c.visual.masks = masks
    c.visual.spike_clusters = spike_clusters
    c.visual.cluster_metadata = cluster_metadata
    c.visual.channel_positions = channel_positions

    show_test(c)

{'fraction_non_alphanumeric': 0.3008827856792545, 'fraction_numerical': 0.005394801373222168, 'mean_word_length': 1.4691283292978208, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6938003', 'n_tokens_mistral': 1044, 'n_tokens_neox': 964, 'n_words': 206}