diff --git a/CHANGELOG.md b/CHANGELOG.md index f2aed32c1..24ed9130d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Improvements -* Update util function `is_ascending_series` to discard nan values and add `check_timestamps_with_nans` fun to check if timestamps contain NaN values [#476](https://github.com/NeurodataWithoutBorders/nwbinspector/issues/476) +* Update util function `is_ascending_series` to discard nan values and add `check_timestamps_without_nans` fun to check if timestamps contain NaN values [#476](https://github.com/NeurodataWithoutBorders/nwbinspector/issues/476) # v0.4.37 diff --git a/docs/best_practices/time_series.rst b/docs/best_practices/time_series.rst index 11f579ed4..919d478c8 100644 --- a/docs/best_practices/time_series.rst +++ b/docs/best_practices/time_series.rst @@ -98,7 +98,7 @@ Ensure that all timestamps are valid numerical values. If gaps in time need to b data into separate :ref:`nwb-schema:sec-TimeSeries` objects with appropriate ``starting_time`` or use the ``timestamps`` vector to explicitly represent time gaps. -Check function: :py:meth:`~nwbinspector.checks.time_series.check_timestamps_with_nans` +Check function: :py:meth:`~nwbinspector.checks.time_series.check_timestamps_without_nans` diff --git a/src/nwbinspector/checks/time_series.py b/src/nwbinspector/checks/time_series.py index ff0dd2d73..18d5cab43 100644 --- a/src/nwbinspector/checks/time_series.py +++ b/src/nwbinspector/checks/time_series.py @@ -94,7 +94,7 @@ def check_timestamps_ascending(time_series: TimeSeries, nelems=200): @register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=TimeSeries) -def check_timestamps_with_nans(time_series: TimeSeries, nelems=200): +def check_timestamps_without_nans(time_series: TimeSeries, nelems=200): """Check if there are NaN values in the timestamps array.""" if time_series.timestamps is not None and np.isnan(time_series.timestamps[:nelems]).any(): return InspectorMessage(message=f"{time_series.name} timestamps contain NaN values.") diff --git a/tests/unit_tests/test_time_series.py b/tests/unit_tests/test_time_series.py index 2d49033c0..2cea34e38 100644 --- a/tests/unit_tests/test_time_series.py +++ b/tests/unit_tests/test_time_series.py @@ -12,7 +12,7 @@ check_data_orientation, check_timestamps_match_first_dimension, check_timestamps_ascending, - check_timestamps_with_nans, + check_timestamps_without_nans, check_missing_unit, check_resolution, check_timestamp_of_the_first_sample_is_not_negative, @@ -261,19 +261,19 @@ def test_check_timestamps_ascending_with_nans_fail(): ) -def test_check_timestamps_with_nans_pass(): +def test_check_timestamps_without_nans_pass(): time_series = pynwb.TimeSeries(name="test_time_series", unit="test_units", data=[1, 2, 3], timestamps=[1, 2, 3]) - assert check_timestamps_with_nans(time_series) is None + assert check_timestamps_without_nans(time_series) is None -def test_check_timestamps_with_nans_fail(): +def test_check_timestamps_without_nans_fail(): time_series = pynwb.TimeSeries( name="test_time_series", unit="test_units", data=[1, 2, 3], timestamps=[np.nan, 2, 3] ) - assert check_timestamps_with_nans(time_series) == InspectorMessage( + assert check_timestamps_without_nans(time_series) == InspectorMessage( message="test_time_series timestamps contain NaN values.", importance=Importance.BEST_PRACTICE_VIOLATION, - check_function_name="check_timestamps_with_nans", + check_function_name="check_timestamps_without_nans", object_type="TimeSeries", object_name="test_time_series", location="/",