Repository: catalystneuro/nwb-conversion-tools (language: python)

Issue:
Drop nwbinspector as a dependency
The only place where we use it is here:
https://github.com/catalystneuro/nwb-conversion-tools/blob/7a52631a236f2be339e443401b0d2ca5162fec0b/src/nwb_conversion_tools/datainterfaces/behavior/movie/moviedatainterface.py#L13

And that is a use of `check_regular_series` which is a super simple function:
https://github.com/NeurodataWithoutBorders/nwbinspector/blob/dd58ddf34cfa0e1d81ec18739e1e3fa2f3e2cd8f/nwbinspector/utils.py#L45-L48

Are we planning on using more functionality? if not, I think that we should maintain a local version of the same function and drop the dependency as a whole. 


Discussion / hints:
I agree, it doesn't seem worth it to have this dependency for such as simple function.
The idea here wasn't just for the free utility function, which avoids duplicated code over multiple repo's, but also to encourage people to use the NWBInspector any time they are writing NWBFiles, which is the purpose of this repo.
I feel that right now we are saving the hypothetical user a pip install at the price of increasing our dependency complexity. My vote is for dropping it until code duplication becomes large enough that the scale is tipped or the need arises from another direction.

Fix patch:
diff --git a/requirements-full.txt b/requirements-full.txt
index 6890a64e7..ea701ee6a 100644
--- a/requirements-full.txt
+++ b/requirements-full.txt
@@ -21,4 +21,3 @@ pyintan==0.3.0
 pyopenephys==1.1.2
 sonpy>=1.7.1
 tiffile==2018.10.18
-nwbinspector==0.4.0
diff --git a/requirements-minimal.txt b/requirements-minimal.txt
index bc819f062..dfa7daef6 100644
--- a/requirements-minimal.txt
+++ b/requirements-minimal.txt
@@ -8,7 +8,6 @@ PyYAML>=5.4
 jsonschema>=3.2.0
 psutil>=5.8.0
 dandi @ git+https://github.com/dandi/dandi-cli.git@9a749401aa2dec2ba59f352205b02a3d8083b1d8  # that uses schema v0.7.x
-nwbinspector>=0.2.3
 spikeextractors>=0.9.9
 spikeinterface>=0.93.0
 neo>=0.9.0
diff --git a/src/nwb_conversion_tools/datainterfaces/behavior/movie/moviedatainterface.py b/src/nwb_conversion_tools/datainterfaces/behavior/movie/moviedatainterface.py
index dc79eb63b..3c3f46dd5 100644
--- a/src/nwb_conversion_tools/datainterfaces/behavior/movie/moviedatainterface.py
+++ b/src/nwb_conversion_tools/datainterfaces/behavior/movie/moviedatainterface.py
@@ -10,7 +10,7 @@
 from pynwb import NWBFile
 from pynwb.image import ImageSeries
 from tqdm import tqdm
-from nwbinspector.utils import check_regular_series
+from nwb_conversion_tools.utils import check_regular_series
 
 from .movie_utils import VideoCaptureContext
 from ....basedatainterface import BaseDataInterface
diff --git a/src/nwb_conversion_tools/utils/__init__.py b/src/nwb_conversion_tools/utils/__init__.py
index 1e21e5ebc..acd6e1422 100644
--- a/src/nwb_conversion_tools/utils/__init__.py
+++ b/src/nwb_conversion_tools/utils/__init__.py
@@ -18,3 +18,5 @@
     fill_defaults,
 )
 from .globbing import decompose_f_string, parse_f_string
+
+from .checks import check_regular_series
diff --git a/src/nwb_conversion_tools/utils/checks.py b/src/nwb_conversion_tools/utils/checks.py
new file mode 100644
index 000000000..2c07b0161
--- /dev/null
+++ b/src/nwb_conversion_tools/utils/checks.py
@@ -0,0 +1,7 @@
+import numpy as np
+
+
+def check_regular_series(series: np.ndarray, tolerance_decimals: int = 9):
+    """General purpose function for checking if the difference between all consecutive points in a series are equal."""
+    uniq_diff_ts = np.unique(np.diff(series).round(decimals=tolerance_decimals))
+    return len(uniq_diff_ts) == 1


Test patch:
diff --git a/tests/test_internals/test_utils.py b/tests/test_internals/test_utils.py
new file mode 100644
index 000000000..2048ddb92
--- /dev/null
+++ b/tests/test_internals/test_utils.py
@@ -0,0 +1,6 @@
+from nwb_conversion_tools.utils import check_regular_series
+
+
+def test_check_regular_series():
+    assert check_regular_series(series=[1, 2, 3])
+    assert not check_regular_series(series=[1, 2, 4])