Skip to content

[BUG] Fix Catch22 TypingError on float32 input with outlier features - #3747

Open
Nandinisingh07 wants to merge 4 commits into
aeon-toolkit:mainfrom
Nandinisingh07:fix-catch22-float32-3721
Open

[BUG] Fix Catch22 TypingError on float32 input with outlier features#3747
Nandinisingh07 wants to merge 4 commits into
aeon-toolkit:mainfrom
Nandinisingh07:fix-catch22-float32-3721

Conversation

@Nandinisingh07

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #3721

What does this implement/fix? Explain your changes.

Catch22 raised a numba.core.errors.TypingError for any float32 input
when outlier_norm=True (the default), via the compiled 3D-input path
_transform_case_numba.

The outlier_series placeholder used for features 13/14
(outlier_include / outlier_include_n) was hardcoded to np.float64.
When the real z-normalised series was computed for a float32 input series,
numba's nopython mode could not unify the float64 placeholder type with
the float32 array being assigned to it, and compilation failed.

The fix derives the placeholder's dtype from the input series itself via
series[:0] / 1, matching the same dtype-promotion rule already used by
_as_normalised_float elsewhere in the codebase (float32 stays float32,
every other dtype normalises to float64).

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

  • Correctness of the dtype-promotion fix (series[:0] / 1) versus the
    original np.empty(0, np.float64) placeholder, and whether this
    aligns with _as_normalised_float's documented promotion rule.
  • Whether the regression test adequately covers the failure mode
    (float32 input, outlier_norm=True and outlier_norm=False).

Any other comments?

Verified manually against all 6 estimators listed in #3721 as affected:
Catch22, Catch22Classifier, Catch22Clusterer,
CanonicalIntervalForestClassifier, DrCIFClassifier, RISTClassifier,
HIVECOTEV2 — all pass cleanly with no dtype errors on float32 input.

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF],
    [DEP] or [GOV]
  • Have you updated the tests to account for these changes?
  • Have you written new tests for your core changes, as applicable?
  • Have you updated the documentation to account for these changes?

The outlier_series placeholder in _transform_case_numba was hardcoded
to float64, which numba's nopython mode could not unify with the
float32 z-normalised series produced for features 13/14
(outlier_include / outlier_include_n), raising a TypingError for
any float32 input when outlier_norm=True.

Fixed by deriving the placeholder's dtype from the input series via
series[:0] / 1, matching the promotion rule _as_normalised_float
already uses elsewhere (float32 stays float32, everything else
becomes float64).

Verified against all dependent estimators: Catch22, Catch22Classifier,
Catch22Clusterer, CanonicalIntervalForestClassifier, DrCIFClassifier,
RISTClassifier, HIVECOTEV2.

Adds a regression test covering both outlier_norm=True and False on
float32 input.
@aeon-actions-bot aeon-actions-bot Bot added bug Something isn't working transformations Transformations package labels Aug 15, 2026
@aeon-actions-bot

Copy link
Copy Markdown
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ bug ].
I have added the following labels to this PR based on the changes made: [ transformations ]. Feel free to change these if they do not properly represent the PR.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, please run pre-commit locally and push the fixes to your PR branch.

Don't hesitate to ask questions on the aeon Discord channel if you have any.

PR CI actions

These checkboxes will add labels to enable or disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Disable numba cache loading
  • Regenerate expected results for testing
  • Push an empty commit to re-run CI checks

@TonyBagnall
TonyBagnall requested a review from baraline August 16, 2026 11:07
@Nandinisingh07

Copy link
Copy Markdown
Contributor Author

Hii!
@MatthewMiddlehurst @TonyBagnall @baraline, just following up on this PR. All checks are now passing. Whenever you get a chance, I’d really appreciate a review. Thank you! 😊

@baraline baraline left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for working on this, some comments

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be replaced with the existing testing utils (make_example_3d_numpy) to generate 3D data. You need to keep the float32 cast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use make_example_3d_numpy with the float32 cast kept — see db44123.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be float64 by default, extracting/storing features with float64 precision on a float32 input is against our goal I think.
Any thoughts on this ? @TonyBagnall @MatthewMiddlehurst

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7a5a783 — c22 is now built via _zeros_promoted(X[0], n_feats * len(X)), so it keeps the input's dtype instead of defaulting to float64.

Comment on lines +1937 to +1940
# / 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we override the value afterward, I'd rather want a helper function to init an empty array to the correct type/shape.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the _zeros_promoted helper as requested in 7a5a783 — it's used both here and for the c22 buffer above.

@Nandinisingh07

Copy link
Copy Markdown
Contributor Author

@baraline @TonyBagnall @MatthewMiddlehurst
I’ve pushed both requested changes. The test now uses make_example_3d_numpy, and _catch22.py now has a _zeros_promoted helper that’s used for both the outlier_series placeholder and the c22 output buffer, so the input dtype is preserved.

All checks are passing. Ready for another look whenever you get a chance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working transformations Transformations package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Catch22 and 6 dependent estimators raise TypingError on float32 input

2 participants