Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Aug 8, 2024
1 parent 0db881e commit 795fc10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 8 additions & 12 deletions src/pynwb/tests/test_aggregated_binned_aligned_spikes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import numpy as np

from pynwb import NWBHDF5IO
from pynwb.testing.mock.file import mock_NWBFile
from pynwb.testing import TestCase, remove_test_file
from pynwb.testing import TestCase
from ndx_binned_spikes import AggregatedBinnedAlignedSpikes


Expand All @@ -17,7 +15,7 @@ def setUp(self):
self.number_of_events = 5

self.bin_width_in_milliseconds = 20.0
self.milliseconds_from_event_to_first_bin = -100.0
self.milliseconds_from_event_to_first_bin = -100.0

# Two units in total and 4 bins, and event with two timestamps
self.data_for_first_event_instance = np.array(
Expand Down Expand Up @@ -62,7 +60,6 @@ def setUp(self):

self.data = np.concatenate([self.data_for_first_event_instance, self.data_for_second_event_instance], axis=1)


def test_constructor(self):
"""Test that the constructor for BinnedAlignedSpikes sets values as expected."""

Expand All @@ -77,24 +74,23 @@ def test_constructor(self):
np.testing.assert_array_equal(aggregated_binnned_align_spikes.event_indices, self.event_indices)
self.assertEqual(aggregated_binnned_align_spikes.bin_width_in_milliseconds, self.bin_width_in_milliseconds)
self.assertEqual(
aggregated_binnned_align_spikes.milliseconds_from_event_to_first_bin, self.milliseconds_from_event_to_first_bin
aggregated_binnned_align_spikes.milliseconds_from_event_to_first_bin,
self.milliseconds_from_event_to_first_bin,
)

self.assertEqual(aggregated_binnned_align_spikes.data.shape[0], self.number_of_units)
self.assertEqual(aggregated_binnned_align_spikes.data.shape[1], self.number_of_events)
self.assertEqual(aggregated_binnned_align_spikes.data.shape[2], self.number_of_bins)


def test_get_single_event_data_method(self):

aggregated_binnned_align_spikes = AggregatedBinnedAlignedSpikes(
bin_width_in_milliseconds=self.bin_width_in_milliseconds,
milliseconds_from_event_to_first_bin=self.milliseconds_from_event_to_first_bin,
data=self.data,
event_indices=self.event_indices,
)



data_for_stimuli_1 = aggregated_binnned_align_spikes.get_data_for_stimuli(event_index=0)
np.testing.assert_allclose(data_for_stimuli_1, self.data_for_first_event_instance)

np.testing.assert_allclose(data_for_stimuli_1, self.data_for_first_event_instance)
6 changes: 4 additions & 2 deletions src/spec/create_extension_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ def main():
neurodata_type_def="AggregatedBinnedAlignedSpikes",
neurodata_type_inc="NWBDataInterface",
default_name="AggregatedBinnedAlignedSpikes",
doc="A data interface for aggregated binned spike data aligned to an multiple events (e.g. a stimuli or the beginning of a trial).",
datasets=[aggregated_binned_aligned_spikes_data, event_indices, units_region],
doc=(
"A data interface for aggregated binned spike data aligned to multiple events "
"(e.g. a stimuli or the beginning of a trial)."
), datasets=[aggregated_binned_aligned_spikes_data, event_indices, units_region],
attributes=[
NWBAttributeSpec(
name="name",
Expand Down

0 comments on commit 795fc10

Please sign in to comment.