Skip to content

Commit

Permalink
Avoid having to set rate=None explitctly when passing timestamps in…
Browse files Browse the repository at this point in the history
… `mock_ElectricalSeries` (#1894)

* set rate as optional value

* changelog

* Update CHANGELOG.md

Co-authored-by: Steph Prince <[email protected]>

* update CHANGELOG.md

* Update src/pynwb/testing/mock/ecephys.py

---------

Co-authored-by: Steph Prince <[email protected]>
  • Loading branch information
h-mayorquin and stephprince authored May 14, 2024
1 parent 86b274d commit 7a0d8b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/pynwb/testing/mock/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 7a0d8b4

Please sign in to comment.