Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aeon/transformations/collection/feature_based/_catch22.py
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,10 @@ def _transform_case_numba(
# typed placeholders; real values are assigned before first use. These
# must be dtype-fixed (not aliases of series) so the kernel also
# compiles for integer input arrays.
outlier_series = np.empty(0, np.float64)
# / 1 applies the same dtype promotion z_normalise_series_with_mean
# uses internally (float32 stays float32, everything else becomes
# float64), so this placeholder always matches the real value's dtype.
outlier_series = series[:0] / 1
have_outlier = False
fft = ac_tw[:0]
have_fft = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1521,3 +1521,24 @@ def track_n(s):
assert abs(np.std(passed_series["p"]) - 1.0) < 1e-10
assert abs(np.mean(passed_series["n"])) < 1e-10
assert abs(np.std(passed_series["n"]) - 1.0) < 1e-10


def test_catch22_float32_output_dtype():
"""Test Catch22 does not raise on float32 input with outlier features.

Regression test: the outlier_series placeholder in _transform_case_numba was
hardcoded to float64, which numba's nopython mode could not unify with a
float32 z-normalised series produced for features 13/14 (outlier_include /
outlier_include_n), raising a TypingError for float32 input.
"""
X = np.random.default_rng(0).standard_normal((6, 1, 40)).astype(np.float32)

# outlier_norm=True exercises the fixed code path (features 13/14)
c22 = Catch22(outlier_norm=True, replace_nans=True)
result = c22.fit_transform(X)
assert result.shape == (6, 22)

# outlier_norm=False takes the other branch -- should still work
c22_no_norm = Catch22(outlier_norm=False, replace_nans=True)
result_no_norm = c22_no_norm.fit_transform(X)
assert result_no_norm.shape == (6, 22)
Loading