Skip to content

Commit

Permalink
change check fun name to check_timestamps_without_nans
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandratrapani committed Aug 8, 2024
1 parent 28acc06 commit e61e22d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/best_practices/time_series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`



Expand Down
2 changes: 1 addition & 1 deletion src/nwbinspector/checks/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
12 changes: 6 additions & 6 deletions tests/unit_tests/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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="/",
Expand Down

0 comments on commit e61e22d

Please sign in to comment.