Skip to content

Commit de3f42a

Browse files
committed
make timeseries with < 3 timestamps exempt from regular_timestamps check
1 parent 25f9f49 commit de3f42a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

nwbinspector/checks/time_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def check_regular_timestamps(
1313
time_series: TimeSeries, time_tolerance_decimals: int = 9, gb_severity_threshold: float = 1.0
1414
):
1515
"""If the TimeSeries uses timestamps, check if they are regular (i.e., they have a constant rate)."""
16-
if time_series.timestamps is not None and check_regular_series(
16+
if time_series.timestamps is not None and len(time_series.timestamps) > 2 and check_regular_series(
1717
series=time_series.timestamps, tolerance_decimals=time_tolerance_decimals
1818
):
1919
timestamps = np.array(time_series.timestamps)

tests/unit_tests/test_time_series.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ def test_check_regular_timestamps():
3535
)
3636

3737

38+
def test_pass_check_regular_timestamps():
39+
"""Should pass because there are only two timestamps"""
40+
assert check_regular_timestamps(
41+
time_series=pynwb.TimeSeries(
42+
name="test_time_series",
43+
unit="test_units",
44+
data=[0, 0],
45+
timestamps=[1.2, 3.2],
46+
)
47+
) is None
48+
49+
3850
def test_check_data_orientation():
3951
assert check_data_orientation(
4052
time_series=pynwb.TimeSeries(

0 commit comments

Comments
 (0)