Skip to content

Commit

Permalink
allow for TimeSeries with just timestamps specified (#1848)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Ruebel <[email protected]>
  • Loading branch information
bendichter and oruebel authored Feb 22, 2024
1 parent 7d19192 commit 65b2a7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pynwb/testing/mock/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def mock_TimeSeries(
conversion: float = 1.0,
timestamps=None,
starting_time: Optional[float] = None,
rate: Optional[float] = 10.0,
rate: Optional[float] = None,
comments: str = "no comments",
description: str = "no description",
control=None,
Expand All @@ -24,6 +24,8 @@ def mock_TimeSeries(
nwbfile: Optional[NWBFile] = None,
offset=0.,
) -> TimeSeries:
if timestamps is None and rate is None:
rate = 10.0 # Hz
time_series = TimeSeries(
name=name or name_generator("TimeSeries"),
data=data if data is not None else np.array([1, 2, 3, 4]),
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ def test_mock(mock_function):
mock_function()


def test_mock_TimeSeries_w_timestamps():
ts = mock_TimeSeries(timestamps=[0, 1, 2, 3])
assert ts.timestamps is not None
assert len(ts.timestamps) == 4


def test_mock_TimeSeries_w_no_time():
ts = mock_TimeSeries()
assert ts.rate == 10.0


@pytest.mark.parametrize("mock_function", mock_functions)
def test_mock_write(mock_function, tmp_path):
if mock_function is mock_NWBFile:
Expand Down

0 comments on commit 65b2a7d

Please sign in to comment.