Skip to content
Open
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
1 change: 1 addition & 0 deletions doc/source/authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ and may not be the current affiliation of a contributor.
* Axel Coiffard-Donaty
* Anthony Mercer
* Aaron Kanzer [53]
* Eva B (evadiva3 on GitHub)

1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Université Claude Bernard Lyon 1
2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France
Expand Down
4 changes: 2 additions & 2 deletions neo/io/nestio.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __read_analogsignals(
if len(np.unique(column_list_no_None)) < len(column_list_no_None):
raise ValueError(
"One or more columns have been specified to contain "
"the same data. Columns were specified to {column_list_no_None}."
f"the same data. Columns were specified to {column_list_no_None}."
""
)

Expand Down Expand Up @@ -348,7 +348,7 @@ def _check_input_sampling_period(self, sampling_period, time_column, time_unit,
if time_column is not None:
data_sampling = np.unique(np.diff(sorted(np.unique(data[:, 1]))))
if len(data_sampling) > 1:
raise ValueError(f"Different sampling distances found in " "data set ({data_sampling})")
raise ValueError(f"Different sampling distances found in data set ({data_sampling})")
else:
dt = data_sampling[0]
else:
Expand Down
14 changes: 14 additions & 0 deletions neo/test/iotest/test_nestio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""

import warnings
from pathlib import Path
from tempfile import TemporaryDirectory

import unittest

Expand All @@ -14,6 +16,18 @@
from neo.test.iotest.common_io_test import BaseTestIO


class TestNestIOErrorMessages(unittest.TestCase):
def test_invalid_columns_and_sampling_distances(self):
with TemporaryDirectory() as directory:
filename = str(Path(directory) / "voltage.dat")
np.savetxt(filename, [[1, 0, -60], [1, 1, -61], [1, 3, -62], [1, 4, -63]])
reader = NestIO(filenames=filename)
with self.assertRaisesRegex(ValueError, r"Columns were specified to \[0, 1, 1\]"):
reader.read_segment(gid_list=[1], value_columns_dat=1)
with self.assertRaisesRegex(ValueError, r"data set \(\[1\. 2\.\]\)"):
reader.read_segment(gid_list=[1], value_columns_dat=2)


class TestNestIO_Analogsignals(BaseTestIO, unittest.TestCase):
ioclass = NestIO
entities_to_download = ["nest"]
Expand Down
10 changes: 10 additions & 0 deletions neo/test/utils/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ def test__get_epochs(self):
assert_arrays_equal(trials_1_2b_b.array_annotations["trial_id"], np.array([1, 2]))
self.assertIsInstance(trials_1_2b_b.array_annotations, ArrayDict)

def test__add_epoch_negative_duration_message(self):
starts = Event(times=[1.0, 2.0] * pq.s)
stops = Event(times=[0.5, 1.5] * pq.s)
seg = Segment()
seg.events = [starts, stops]

# the offending durations must appear in the error message
with self.assertRaisesRegex(ValueError, r"Requested durations \[-0\.5 -0\.5\] s"):
add_epoch(seg, starts, stops)

def test__add_epoch(self):
starts = Event(times=[0.5, 10.0, 25.2] * pq.s)
starts.annotate(event_type="trial start", nix_name="neo.event.0")
Expand Down
2 changes: 1 addition & 1 deletion neo/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def add_epoch(segment, event1, event2=None, pre=0 * pq.s, post=0 * pq.s, attach_
durations = event2.times + post - times

if any(durations < 0):
raise ValueError(f"Can not create epoch with negative duration. " "Requested durations {durations}.")
raise ValueError(f"Can not create epoch with negative duration. Requested durations {durations}.")
elif any(durations == 0):
raise ValueError("Can not create epoch with zero duration.")

Expand Down