Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Sep 6, 2024
1 parent 5470bde commit 31b2d4c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ data_for_first_stimuli = np.array(
],
)

# Also two units and 4 bins but this event appeared three times
# Also two units and 4 bins but this condition occured three times
data_for_second_stimuli = np.array(
[
# Unit 1
Expand Down
28 changes: 20 additions & 8 deletions src/pynwb/tests/test_binned_aligned_spikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ def test_constructor(self):

np.testing.assert_array_equal(binned_aligned_spikes.data, self.data)
np.testing.assert_array_equal(binned_aligned_spikes.event_timestamps, self.event_timestamps)



self.assertEqual(binned_aligned_spikes.bin_width_in_milliseconds, self.bin_width_in_milliseconds)
self.assertEqual(
binned_aligned_spikes.milliseconds_from_event_to_first_bin, self.milliseconds_from_event_to_first_bin
)

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

def test_constructor_units_region(self):

Expand Down Expand Up @@ -216,9 +219,9 @@ def test_constructor(self):
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)
self.assertEqual(aggregated_binnned_align_spikes.number_of_units, self.number_of_units)
self.assertEqual(aggregated_binnned_align_spikes.number_of_events, self.number_of_events)
self.assertEqual(aggregated_binnned_align_spikes.data.number_of_bins, self.number_of_bins)

def test_get_single_condition_data_methods(self):

Expand Down Expand Up @@ -267,6 +270,9 @@ def test_roundtrip_acquisition(self):
"""

# Testing here
number_of_units = 5
number_of_bins = 10
number_of_events = 100
self.binned_aligned_spikes = mock_BinnedAlignedSpikes(number_of_conditions=3, condition_labels=["a", "b", "c"])

self.nwbfile.add_acquisition(self.binned_aligned_spikes)
Expand All @@ -276,8 +282,14 @@ def test_roundtrip_acquisition(self):

with NWBHDF5IO(self.path, mode="r", load_namespaces=True) as io:
read_nwbfile = io.read()
read_container = read_nwbfile.acquisition["BinnedAlignedSpikes"]
self.assertContainerEqual(self.binned_aligned_spikes, read_container)
read_binned_aligned_spikes = read_nwbfile.acquisition["BinnedAlignedSpikes"]
self.assertContainerEqual(self.binned_aligned_spikes, read_binned_aligned_spikes)

assert read_binned_aligned_spikes.number_of_units == number_of_units
assert read_binned_aligned_spikes.number_of_bins == number_of_bins
assert read_binned_aligned_spikes.number_of_events == number_of_events



def test_roundtrip_processing_module(self):
self.binned_aligned_spikes = mock_BinnedAlignedSpikes()
Expand Down

0 comments on commit 31b2d4c

Please sign in to comment.