Repository: sktime/sktime

Issue:
[BUG] ShapeletTransformClassifier numba error when dtype is not float64
**Describe the bug**
Seems that when using `ShapeletTransformClassifier` there is some Numba accelerated functions that break if the data in the input data frame are of type `int32`.

**To Reproduce**
MRE as below:

```python
import warnings
warnings.simplefilter('ignore', category=FutureWarning)

import numpy as np
import pandas as pd

from sklearn.model_selection import train_test_split

from sktime.classification.shapelet_based import ShapeletTransformClassifier
from sktime.contrib.vector_classifiers._rotation_forest import RotationForest

# make fake data
data = pd.DataFrame(np.random.random((5000, 250))).astype(np.float32)

# reshape to input into Shapelet Classifier
data4train = data.apply(lambda row: pd.Series({
  'time-series': pd.Series(row.values)
}), axis=1)

# make targets
targets = pd.Series(2500 * [1] + 2500 * [0])

# train test split
X_train, X_test, y_train, y_test = train_test_split(
  data4train, targets, test_size=0.7, random_state=42
)

# train
clf = ShapeletTransformClassifier(
    estimator=RotationForest(n_estimators=3),
    n_shapelet_samples=500,
    max_shapelets=20,
    batch_size=100,
)

clf.fit(X_train, y_train)
```

**Expected behavior**
will not throw an error, and also enforce conversion to float32 or float64 within the classifier?
**Additional context**
removing conversion to `float32` (hence `dtype == float64`) will make the code running without issues.

**Versions**
numba 0.55.1
sklearn 0.24.1
sktime 0.11.0
pandas 1.4.2
python 3.8.10

**Stacktrace output**
```bash
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify array(float64, 1d, C) and array(float32, 1d, C) for 'X_n.2', defined at /path_to_mypython/python/lib/python3.8/site-packages/sktime/utils/numba/general.py (39)

File "../python/lib/python3.8/site-packages/sktime/utils/numba/general.py", line 39:
def z_normalise_series(X):
    <source elided>

    return X_n
```


Discussion:
Yes, indeed. I think we should look at all the `numba` based code and ensure conversion to float?
Thanks for that we will take a look @MatthewMiddlehurst might be best placed, I think you wrote it?
The numba function is cache'd using float64. Removing the cache=true will fix this or having two functions one for floatt64 and one for float32 and do an if check before function call to call the correct function.

If you choose the latter happy to show you how to specify the type for a numba function to specify float32 or float64 for a function.

Resolving patch:
diff --git a/sktime/utils/numba/general.py b/sktime/utils/numba/general.py
--- a/sktime/utils/numba/general.py
+++ b/sktime/utils/numba/general.py
@@ -34,6 +34,5 @@ def z_normalise_series(X):
     if std > 0:
         X_n = (X - np.mean(X)) / std
     else:
-        X_n = np.zeros(len(X))
-
+        X_n = X - np.mean(X)
     return X_n


Test patch:
diff --git a/sktime/utils/estimators/tests/__init__.py b/sktime/utils/estimators/tests/__init__.py
--- a/sktime/utils/estimators/tests/__init__.py
+++ b/sktime/utils/estimators/tests/__init__.py
@@ -1,4 +1,4 @@
 # -*- coding: utf-8 -*-
-"""Tests for Mock Estimnators."""
+"""Tests for Mock Estimators."""
 
 __author__ = ["ltsaprounis"]
diff --git a/sktime/utils/numba/tests/__init__.py b/sktime/utils/numba/tests/__init__.py
new file mode 100644
--- /dev/null
+++ b/sktime/utils/numba/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+"""Tests for numba utils."""
+
+__author__ = ["TonyBagnall"]
diff --git a/sktime/utils/numba/tests/test_general.py b/sktime/utils/numba/tests/test_general.py
new file mode 100644
--- /dev/null
+++ b/sktime/utils/numba/tests/test_general.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+"""Tests for numba functions."""
+
+__author__ = ["TonyBagnall"]
+
+import numpy as np
+import pytest
+from numpy.testing import assert_array_equal
+
+from sktime.utils.numba.general import z_normalise_series
+
+DATATYPES = ["int32", "int64", "float32", "float64"]
+
+
+@pytest.mark.parametrize("type", DATATYPES)
+def test_z_normalise_series(type):
+    """Test the function z_normalise_series."""
+    a = np.array([2, 2, 2], dtype=type)
+    a_expected = np.array([0, 0, 0], dtype=type)
+    a_result = z_normalise_series(a)
+    assert_array_equal(a_result, a_expected)