Repository: NeurodataWithoutBorders/nwbinspector (language: python)

Issue:
[Bug]: prompted rate for regular timestamps check not in Hz
### What happened?

The inspector message in [`check_regular_timestamps`](https://github.com/NeurodataWithoutBorders/nwbinspector/blob/6110d444e6b10acb57f80d410985e09ec5d26f4b/src/nwbinspector/checks/time_series.py#L27-L34) prompts the user to specify a rate instead of timestamps if a `TimeSeries` has a constant sampling rate. 

However, the prompted rate is the interval between the timestamps:
```python
rate={time_series.timestamps[1] - time_series.timestamps[0]}
```
I think the rate should instead be the inverse of the interval between timestamps (1/s) to reflect the sampling rate in Hz that the user would specify when creating a `TimeSeries`?
```python
rate={1 / (time_series.timestamps[1] - time_series.timestamps[0])}"
```

### Operating System

M1 macOS

### Python Version

3.12

### Were you streaming with ROS3?

No

### Package Versions

<details> Copy and paste your output here </details>

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/NeurodataWithoutBorders/nwbinspector/blob/dev/.github/CODE_OF_CONDUCT.rst)
- [X] Have you ensured this bug was not already [reported](https://github.com/neurodatawithoutborders/nwbinspector/issues)?
- [X] To the best of your ability, have you ensured this is a bug within the code that checks the NWBFile, rather than a bug in the NWBFile reader (e.g., [PyNWB](https://github.com/NeurodataWithoutBorders/pynwb) or [MatNWB](https://github.com/NeurodataWithoutBorders/matnwb))?


Discussion / hints:
Ooops, thought we fixed this a while back

@stephprince are you willing to make a PR for this?
yes I can make a PR for this!

Fix patch:
diff --git a/.github/workflows/dandi_release.yml b/.github/workflows/dandi_release.yml
index 51be35aa2..7697a71dc 100644
--- a/.github/workflows/dandi_release.yml
+++ b/.github/workflows/dandi_release.yml
@@ -42,8 +42,8 @@ jobs:
         python -m pip install --upgrade pip wheel
         pip install "dandi[extras,test]"
 
-    - name: Install dev versions of NWB Inspector
-      run: pip install git+https://github.com/NeurodataWithoutBorders/nwbinspector
+    - name: Install this branch of NWB Inspector
+      run: pip install -e .
 
-    - name: Run all tests
+    - name: Run all NWB Inspector tests
       run: python -m pytest -s -v
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9cb11a883..4bcd996f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Upcoming
 
+### Fixes
+
+* Fixed the suggested rate in `check_regular_timestamps` to be in Hz [#467](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/467)
+
 # v0.4.35
 
 ### Fixes
diff --git a/src/nwbinspector/checks/time_series.py b/src/nwbinspector/checks/time_series.py
index adab06594..6c3c104e7 100644
--- a/src/nwbinspector/checks/time_series.py
+++ b/src/nwbinspector/checks/time_series.py
@@ -18,6 +18,7 @@ def check_regular_timestamps(
         time_series.timestamps is not None
         and len(time_series.timestamps) > 2
         and is_regular_series(series=time_series.timestamps, tolerance_decimals=time_tolerance_decimals)
+        and (time_series.timestamps[1] - time_series.timestamps[0]) != 0
     ):
         timestamps = np.array(time_series.timestamps)
         if timestamps.size * timestamps.dtype.itemsize > gb_severity_threshold * 1e9:
@@ -29,7 +30,7 @@ def check_regular_timestamps(
             message=(
                 "TimeSeries appears to have a constant sampling rate. "
                 f"Consider specifying starting_time={time_series.timestamps[0]} "
-                f"and rate={time_series.timestamps[1] - time_series.timestamps[0]} instead of timestamps."
+                f"and rate={1 / (time_series.timestamps[1] - time_series.timestamps[0])} instead of timestamps."
             ),
         )
 


Test patch:
diff --git a/tests/test_inspector.py b/tests/test_inspector.py
index 4db14f219..8fd4808f8 100644
--- a/tests/test_inspector.py
+++ b/tests/test_inspector.py
@@ -158,7 +158,7 @@ def test_inspect_all(self):
             InspectorMessage(
                 message=(
                     "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 "
-                    "and rate=2.0 instead of timestamps."
+                    "and rate=0.5 instead of timestamps."
                 ),
                 importance=Importance.BEST_PRACTICE_VIOLATION,
                 severity=Severity.LOW,
@@ -194,7 +194,7 @@ def test_inspect_all(self):
             InspectorMessage(
                 message=(
                     "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 "
-                    "and rate=2.0 instead of timestamps."
+                    "and rate=0.5 instead of timestamps."
                 ),
                 importance=Importance.BEST_PRACTICE_VIOLATION,
                 severity=Severity.LOW,
@@ -225,7 +225,7 @@ def test_inspect_all_parallel(self):
                 InspectorMessage(
                     message=(
                         "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 "
-                        "and rate=2.0 instead of timestamps."
+                        "and rate=0.5 instead of timestamps."
                     ),
                     importance=Importance.BEST_PRACTICE_VIOLATION,
                     severity=Severity.LOW,
@@ -263,7 +263,7 @@ def test_inspect_all_parallel(self):
                 InspectorMessage(
                     message=(
                         "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 "
-                        "and rate=2.0 instead of timestamps."
+                        "and rate=0.5 instead of timestamps."
                     ),
                     importance=Importance.BEST_PRACTICE_VIOLATION,
                     severity=Severity.LOW,
@@ -292,7 +292,7 @@ def test_inspect_nwbfile(self):
             InspectorMessage(
                 message=(
                     "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and "
-                    "rate=2.0 instead of timestamps."
+                    "rate=0.5 instead of timestamps."
                 ),
                 severity=Severity.LOW,
                 importance=Importance.BEST_PRACTICE_VIOLATION,
@@ -542,7 +542,7 @@ def test_inspect_nwbfile_dandi_config(self):
             InspectorMessage(
                 message=(
                     "TimeSeries appears to have a constant sampling rate. "
-                    "Consider specifying starting_time=1.2 and rate=2.0 instead of timestamps."
+                    "Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps."
                 ),
                 importance=Importance.BEST_PRACTICE_VIOLATION,
                 check_function_name="check_regular_timestamps",
diff --git a/tests/true_nwbinspector_default_report.txt b/tests/true_nwbinspector_default_report.txt
index 846255249..aa0447eba 100644
--- a/tests/true_nwbinspector_default_report.txt
+++ b/tests/true_nwbinspector_default_report.txt
@@ -25,7 +25,7 @@ Found 5 issues over 2 files:
 ==========================
 
 1.2  ./testing0.nwb and 1 other file: check_regular_timestamps - 'TimeSeries' object at location '/acquisition/test_time_series_2'
-       Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=2.0 instead of timestamps.
+       Message: TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 instead of timestamps.
 
 2  BEST_PRACTICE_SUGGESTION
 ===========================
diff --git a/tests/unit_tests/test_time_series.py b/tests/unit_tests/test_time_series.py
index fe06bcd31..88e831603 100644
--- a/tests/unit_tests/test_time_series.py
+++ b/tests/unit_tests/test_time_series.py
@@ -34,7 +34,7 @@ def test_check_regular_timestamps():
         )
     ) == InspectorMessage(
         message=(
-            "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=2.0 "
+            "TimeSeries appears to have a constant sampling rate. Consider specifying starting_time=1.2 and rate=0.5 "
             "instead of timestamps."
         ),
         importance=Importance.BEST_PRACTICE_VIOLATION,