Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for TimeSeries with just timestamps specified #1848

Merged
merged 2 commits into from
Feb 22, 2024
Merged
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
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
Loading