From f69249a42acfc713d19d7f5d9f5be3e10c5b5055 Mon Sep 17 00:00:00 2001 From: Eva B <250416784+evadiva3@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:28:20 -0800 Subject: [PATCH 1/2] Interpolate values in epoch and NEST error messages --- doc/source/authors.rst | 1 + neo/io/nestio.py | 4 ++-- neo/test/iotest/test_nestio.py | 14 ++++++++++++++ neo/test/utils/test_misc.py | 10 ++++++++++ neo/utils/misc.py | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/source/authors.rst b/doc/source/authors.rst index 357faaf52..f6ec68038 100644 --- a/doc/source/authors.rst +++ b/doc/source/authors.rst @@ -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 diff --git a/neo/io/nestio.py b/neo/io/nestio.py index cea34cec0..37aca2682 100644 --- a/neo/io/nestio.py +++ b/neo/io/nestio.py @@ -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}." "" ) @@ -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: diff --git a/neo/test/iotest/test_nestio.py b/neo/test/iotest/test_nestio.py index 86d7fab97..06f53637c 100644 --- a/neo/test/iotest/test_nestio.py +++ b/neo/test/iotest/test_nestio.py @@ -3,6 +3,8 @@ """ import warnings +from pathlib import Path +from tempfile import TemporaryDirectory import unittest @@ -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"] diff --git a/neo/test/utils/test_misc.py b/neo/test/utils/test_misc.py index 2a7f7af03..fa1fb28f5 100644 --- a/neo/test/utils/test_misc.py +++ b/neo/test/utils/test_misc.py @@ -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") diff --git a/neo/utils/misc.py b/neo/utils/misc.py index d9e7e0517..42d9b5527 100644 --- a/neo/utils/misc.py +++ b/neo/utils/misc.py @@ -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.") From 8970bc976f46bd6f0156af2c344d060a474c2a0b Mon Sep 17 00:00:00 2001 From: evadiva3 Date: Wed, 18 Nov 2026 20:02:35 -0500 Subject: [PATCH 2/2] Retry Read the Docs after infrastructure timeout