Repository: eonu/sequentia

Issue:
Fix independent DTW
### Has this already been reported?

- [X] This is a new bug!

### Expected behaviour

Below should be calling `self._dtw1d`.

https://github.com/eonu/sequentia/blob/506228868378c767f5b67d208fa4c2dc72c8b52d/sequentia/models/knn/base.py#L209

Add a unit test.

### Observed behaviour

Calling `self._dtw` incorrectly.

### Code to reproduce

```Python
N/A
```


### Version details

```Text
N/A
```


Discussion:
coveralls: ## Pull Request Test Coverage Report for [Build 587dc8de-10f4-4295-832b-1504ba8e266d](https://coveralls.io/builds/66895266)


### Details

* **0** of **0**   changed or added relevant lines in **0** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.2%**) to **90.868%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/66895266/badge)](https://coveralls.io/builds/66895266) |
| :-- | --: |
| Change from base [Build d31d7ff8-d7b5-47c4-bbc7-8b83b833affb](https://coveralls.io/builds/66657826): |  0.2% |
| Covered Lines: | 2199 |
| Relevant Lines: | 2420 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/sequentia/models/knn/base.py b/sequentia/models/knn/base.py
index f60687c..d2d91e9 100644
--- a/sequentia/models/knn/base.py
+++ b/sequentia/models/knn/base.py
@@ -206,7 +206,7 @@ class KNNMixin:
 
         def dtw(a: FloatArray, b: FloatArray) -> float:
             """Windowed DTW wrapper function."""
-            return self._dtw(a, b, window=window)
+            return self._dtw1d(a, b, window=window)
 
         return np.sum([dtw(A[:, i], B[:, i]) for i in range(A.shape[1])])
 


Test patch:
diff --git a/tests/unit/test_models/knn/test_classifier.py b/tests/unit/test_models/knn/test_classifier.py
index ce3b0e8..15f4544 100644
--- a/tests/unit/test_models/knn/test_classifier.py
+++ b/tests/unit/test_models/knn/test_classifier.py
@@ -46,18 +46,32 @@ def assert_fit(clf: KNNClassifier, /, *, data: SequentialDataset) -> None:
 
 @pytest.mark.parametrize("k", [1, 2, 5])
 @pytest.mark.parametrize("weighting", [None, lambda x: np.exp(-x)])
+@pytest.mark.parametrize("independent", [False, True])
 def test_classifier_e2e(
     helpers: t.Any,
     request: SubRequest,
-    k: int,
-    weighting: t.Callable | None,
     dataset: SequentialDataset,
     random_state: np.random.RandomState,
+    *,
+    k: int,
+    weighting: t.Callable | None,
+    independent: bool,
 ) -> None:
-    clf = KNNClassifier(k=k, weighting=weighting, random_state=random_state)
+    clf = KNNClassifier(
+        k=k,
+        weighting=weighting,
+        independent=independent,
+        random_state=random_state,
+    )
 
     assert clf.k == k
     assert clf.weighting == weighting
+    assert clf.independent == independent
+
+    if independent:
+        assert clf._dtw().__name__ == "_dtwi"
+    else:
+        assert clf._dtw().__name__ == "_dtwd"
 
     data = dataset.copy()
     data._X = data._X[:, :1]  # only use one feature