Skip to content

[BUG] Preserve input dtype in shift_scale_invariant zero-padding - #3773

Open
Jorge-Polanco-Roque wants to merge 2 commits into
aeon-toolkit:mainfrom
Jorge-Polanco-Roque:fix/shift-scale-invariant-float32
Open

[BUG] Preserve input dtype in shift_scale_invariant zero-padding#3773
Jorge-Polanco-Roque wants to merge 2 commits into
aeon-toolkit:mainfrom
Jorge-Polanco-Roque:fix/shift-scale-invariant-float32

Conversation

@Jorge-Polanco-Roque

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #3722.

What does this implement/fix? Explain your changes.

shift_scale_invariant_distance (and KSpectralCentroid, which uses it) raised a numba TypingError on float32 input: the zero-padding in the shift branches of _univariate_shift_scale_invariant_distance was built with an untyped np.zeros, which defaults to float64, so shifted_y could not unify across the branches (float32 from y, float64 from the padded ones). Passing dtype=y.dtype to both zero-padding branches keeps everything at the input dtype.

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

No.

Any other comments?

Verified shift_scale_invariant_distance and KSpectralCentroid now fit/run on float32, matching the float64 result.

PR checklist

For all contributions
  • The PR title starts with [BUG].
  • I've added a test (test_shift_scale_invariant_distance_float32); verified it fails without the fix. ruff is green.
  • I'll add myself via the @all-contributors bot after merge.

The zero-padding in the shift branches of the shift-scale-invariant distance
used an untyped np.zeros (float64), so shifted_y could not unify with float32
input inside the numba-compiled function, raising a TypingError. Pass
dtype=y.dtype in both branches.

Fixes aeon-toolkit#3722
@aeon-actions-bot aeon-actions-bot Bot added bug Something isn't working distances Distances package labels Aug 30, 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: [ distances ]. 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

@Jorge-Polanco-Roque

Copy link
Copy Markdown
Author

The run-notebook-examples failure is unrelated to this change: it's examples/visualisation/plotting_estimators.ipynb raising ImportError: You must install graphviz ... for plot_model to work (graphviz missing in the CI environment). This PR only touches the shift_scale_invariant distance; examples/distances/distances.ipynb and plotting_distances.ipynb pass.

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

Labels

bug Something isn't working distances Distances package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] shift_scale_invariant_distance and KSpectralCentroid raise TypingError on float32 input

2 participants