Repository: sktime/sktime

Issue:
[BUG] `numba` related failures on main from `tslearn` `lcss`
On main, it seems we have the following `numba` related failures:

```
During: resolving callee type: type(CPUDispatcher(<function _local_squared_dist at 0x14fc267a0>))
During: typing of call at /Users/runner/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/tslearn/metrics/dtw_variants.py (1421)
```

This is not related to the recent newer `numba` release as we did not upgrade yet.

For test runs with the failures, see here: https://github.com/sktime/sktime/actions/runs/6424459407/job/17445296470?pr=5083



Discussion:
I am supposing that the following is the relevant part of the error message:

```
  >>> iadd(float64, array(float64, 1d, C))
 
There are 18 candidate implementations:
  - Of which 16 did not match due to:
  Overload of function 'iadd': File: <numerous>: Line N/A.
    With argument(s): '(float64, array(float64, 1d, C))':
   No match.
  - Of which 2 did not match due to:
  Operator Overload in function 'iadd': File: unknown: Line unknown.
    With argument(s): '(float64, array(float64, 1d, C))':
   No match for registered cases:
    * (int64, int64) -> int64
    * (int64, uint64) -> int64
    * (uint64, int64) -> int64
    * (uint64, uint64) -> uint64
    * (float32, float32) -> float32
    * (float64, float64) -> float64
    * (complex64, complex64) -> complex64
    * (complex128, complex128) -> complex128

During: typing of intrinsic-call at /Users/runner/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/tslearn/metrics/dtw_variants.py (20)
```


I guess the error is caused when running this test : 
```
from sktime.dists_kernels.lcss import LcssTslearn
from sktime.utils._testing.scenarios_transformers_pairwise import TransformerPairwisePanelTransformAsymm
from sktime.dists_kernels.tests.test_all_dist_kernels import TestAllPanelTransformers

scenario = TransformerPairwisePanelTransformAsymm()
estimator_instance = LcssTslearn(global_constraint='sakoe_chiba', sakoe_chiba_radius=2)
testallpaneltransformers = TestAllPanelTransformers()
testallpaneltransformers.test_pairwise_transformers_panel(estimator_instance,scenario)
```
Exactly, a small code snippet to reproduce the error is:

```python
from sktime.datasets import load_unit_test
from sktime.dists_kernels.lcss import LcssTslearn

X, _ = load_unit_test(return_type="pd-multiindex")  # doctest: +SKIP
d = LcssTslearn()  # doctest: +SKIP
distmat = d.transform(X)  # doctest: +SKIP
```

* I tested it also with commit d4a0dc3f (I think this is the last one before the release 0.23.0. There, this error also exists. However, I could not find out the exact dependencies of the state of this commit, thus it is not fully reproducing the state three weeks ago.

* I installed also sktime 0.23.0 in a fresh environment. There the error exists too.

### Observations:

The method `pwtrafo(X, X2, **params)` in `ts_learn` is called with a list containing a two-dimensional array. Further, the method `lcss` in `dtw_variants.py` of `tslearn` is calling `njit_lcss` with arrays that have the shape (42,24,1). Interestingly, the call of `njit_lcss` would work if the array has the shape (42,24).  The docstring of `njit_lcss` says that the shape of the series should be `shape = (sz1,)`. 

### Open Questions:
*  why is the shape (42,24) working?
*  why do we have not previously observed it?

### Possible fix
* Try to change the shape. However, I do not know if this leads still to correct results!


Resolving patch:
diff --git a/sktime/dists_kernels/base/adapters/_tslearn.py b/sktime/dists_kernels/base/adapters/_tslearn.py
--- a/sktime/dists_kernels/base/adapters/_tslearn.py
+++ b/sktime/dists_kernels/base/adapters/_tslearn.py
@@ -140,4 +140,7 @@ def _transform(self, X, X2=None):
         if isinstance(X2, list):
             X2 = self._coerce_df_list_to_list_of_arr(X2)
 
-        return self._eval_tslearn_pwtrafo(X, X2)
+        if self._is_cdist:
+            return self._eval_tslearn_pwtrafo(X, X2)
+        else:
+            return self._eval_tslearn_pwtrafo_vectorized(X, X2)


Test patch: