From 7a0d8b47eba2f67fcd40c53571de77e969b97724 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Mon, 13 May 2024 20:10:35 -0600 Subject: [PATCH] Avoid having to set `rate=None` explitctly when passing timestamps in `mock_ElectricalSeries` (#1894) * set rate as optional value * changelog * Update CHANGELOG.md Co-authored-by: Steph Prince <40640337+stephprince@users.noreply.github.com> * update CHANGELOG.md * Update src/pynwb/testing/mock/ecephys.py --------- Co-authored-by: Steph Prince <40640337+stephprince@users.noreply.github.com> --- CHANGELOG.md | 5 +++++ src/pynwb/testing/mock/ecephys.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 327541002..4f61a0587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # PyNWB Changelog +## PyNWB 2.8.0 (Upcoming) + +### Enhancements and minor changes +- Set rate default value inside `mock_ElectricalSeries` to avoid having to set `rate=None` explicitly when passing timestamps. @h-mayorquin [#1894](https://github.com/NeurodataWithoutBorders/pynwb/pull/1894) + ## PyNWB 2.7.0 (May 2, 2024) ### Enhancements and minor changes diff --git a/src/pynwb/testing/mock/ecephys.py b/src/pynwb/testing/mock/ecephys.py index 36796c267..0669e7493 100644 --- a/src/pynwb/testing/mock/ecephys.py +++ b/src/pynwb/testing/mock/ecephys.py @@ -70,7 +70,7 @@ def mock_ElectricalSeries( name: Optional[str] = None, description: str = "description", data=None, - rate: float = 30000.0, + rate: Optional[float] = None, timestamps=None, starting_time: Optional[float] = None, electrodes: Optional[DynamicTableRegion] = None, @@ -80,6 +80,10 @@ def mock_ElectricalSeries( conversion: float = 1.0, offset: float = 0., ) -> ElectricalSeries: + + # Set a default rate if timestamps are not provided + rate = 30_000.0 if (timestamps is None and rate is None) else rate + electrical_series = ElectricalSeries( name=name or name_generator("ElectricalSeries"), description=description,