Skip to content

BUG: row_* functions in numba stats upcast float32 input to float64 - #3749

Open
Nandinisingh07 wants to merge 1 commit into
aeon-toolkit:mainfrom
Nandinisingh07:fix-row-functions-dtype-3724
Open

BUG: row_* functions in numba stats upcast float32 input to float64#3749
Nandinisingh07 wants to merge 1 commit into
aeon-toolkit:mainfrom
Nandinisingh07:fix-row-functions-dtype-3724

Conversation

@Nandinisingh07

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Closes #3724

What does this implement/fix? Explain your changes.

The row_* functions in aeon/utils/numba/stats.py (row_mean,
row_count_mean_crossing, row_count_above_mean, row_median,
row_quantile25, row_quantile75, row_std, row_numba_min,
row_numba_max, row_slope, row_iqr, row_ppv) allocated their
output array with np.zeros(X.shape[0]), which always defaults to
float64 regardless of the input array's dtype. For float32 input
this silently upcast the result to float64, doubling memory usage
for the returned array.

This PR replaces the untyped allocation with one derived from the
input dtype, so float32 input now returns float32 output and
float64 input continues to return float64.

Also includes a cherry-picked fix for a related numba.TypingError
in Catch22._transform (_outlier_include), which surfaced while
verifying this change against downstream estimators that consume
these row functions (it failed to unify float64/float32 arrays
for outlier_series).

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

No.

Any other comments?

Added a regression test, test_row_functions_preserve_dtype, in
aeon/utils/numba/tests/test_stats.py covering all affected
functions for both float32 and float64 input.

Verified no downstream regressions by running the fix against
CanonicalIntervalForestClassifier/Regressor, DrCIFClassifier/
Regressor, SupervisedTimeSeriesForest, RISTClassifier,
SevenNumberSummary, RandomIntervals, and SupervisedIntervals
all pass. Also ran the full test_stats.py,
interval_based, and feature_based/catch22 test suites locally
(42 passed, 6 skipped as expected).

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 16, 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

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.

[MNT] utils/numba/stats.py row_* functions return float64 arrays for float32 input

1 participant