You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improves test coverage for several modules in aeon.transformations.series
towards 100%, fixing four real bugs uncovered along the way and removing
dead/unreachable code.
Bugs fixed
ClaSPTransformer crashes with scoring_metric="F1": _binary_f1_score
divided by zero (tp / (tp + fp) etc.) whenever a split produced no
predicted/true positives for a class. Under real numba JIT compilation this
raised ZeroDivisionError (not just a nan/warning as under plain numpy),
crashing fit/transform outright on realistic data. Precision/recall are
now defined as 0.0 when their denominator is zero, matching the standard
convention for undefined precision/recall.
ClaSPTransformer crashes when the series is short relative to the
window length: _compute_distances_iterative's fallback for "fewer than k candidate neighbours exist" tried to assign an (n,)-shaped array of
indices into a (k,)-shaped row when n < k, raising a shape-mismatch ValueError. Fixed by cycling through the available indices to fill the
row instead.
AutoCorrelationSeriesTransformer raised the wrong exception type: the
"lags too large for series length" error message referenced a nonexistent self._n_lags attribute, so the intended ValueError was masked by an AttributeError instead.
STLSeriesTransformer/MSTLSeriesTransformer never used Numba by
default: _resolve_use_numba_local returned bool(self.use_numba),
which silently turns the documented default use_numba=None ("auto: use
Numba if available, otherwise NumPy") into False. So the default
configuration always took the slower NumPy path, even with Numba
installed. The existing parity test only passed because both backends are
numerically equivalent by design — it never checked which one actually
ran. Fixed so None stays None and defers to the existing
Numba-availability auto-detection. A follow-up issue (#) tracks a
bigger question this surfaced — whether Numba's optional-import fallback
in _stl.py still makes sense given it's a core dependency — which is out
of scope here; _stl.py's own test coverage is intentionally left
untouched in this PR pending that decision.
Dead/unreachable code removed
Unused _sliding_window helper in _clasp.py (not called anywhere).
Duplicate elif/exact-complement branches in _yeojohnson.py
(elif lmbda == 0 after if lmbda != 0, etc.) and _clasp.py's _check_scoring_metric — these conditions can never be false given the
prior branch, so simplified to else.
An unreachable else branch in _pla.py's SWAB loop: analytically, current_data_point can never exceed len(X) since _best_line never
returns more elements than remain in the series, so the "data exhausted"
branch was dead.
Coverage
Brought the following modules to ~96–100% statement coverage (measured with NUMBA_DISABLE_JIT=1, since coverage.py cannot trace into compiled @njit
code): _collection_wrapper.py, _boxcox.py, _yeojohnson.py, _scaled_logit.py, base.py, compose/_pipeline.py, compose/_identity.py, smoothing/_rms.py, _diff.py, _log.py, _warping.py, _dobin.py, _bkfilter.py, _pla.py, _clasp.py, _mstl.py. Added two new test files
(test_collection_wrapper.py, test_log.py) for previously untested
transformers.
A few branches are intentionally left uncovered: defensive RuntimeError
guards and generic roc_auc-style edge cases that are unreachable given how
they're actually invoked in this codebase, plus code gated behind the statsmodels/stumpy soft dependencies (not installed in this environment). _stl.py itself is excluded from the coverage pass for now (see the Numba
bug note above).
I have added the following labels to this PR based on the title: [ bug, maintenance ].
I would have added the following labels to this PR based on the changes made: [ transformations ], however some package labels are already present.
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 aeonDiscord 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingcoverageCode requiring greater test coveragemaintenanceContinuous integration, unit testing & package distributiontransformationsTransformations package
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves test coverage for several modules in
aeon.transformations.seriestowards 100%, fixing four real bugs uncovered along the way and removing
dead/unreachable code.
Bugs fixed
ClaSPTransformercrashes withscoring_metric="F1":_binary_f1_scoredivided by zero (
tp / (tp + fp)etc.) whenever a split produced nopredicted/true positives for a class. Under real numba JIT compilation this
raised
ZeroDivisionError(not just anan/warning as under plain numpy),crashing
fit/transformoutright on realistic data. Precision/recall arenow defined as
0.0when their denominator is zero, matching the standardconvention for undefined precision/recall.
ClaSPTransformercrashes when the series is short relative to thewindow length:
_compute_distances_iterative's fallback for "fewer thankcandidate neighbours exist" tried to assign an(n,)-shaped array ofindices into a
(k,)-shaped row whenn < k, raising a shape-mismatchValueError. Fixed by cycling through the available indices to fill therow instead.
AutoCorrelationSeriesTransformerraised the wrong exception type: the"lags too large for series length" error message referenced a nonexistent
self._n_lagsattribute, so the intendedValueErrorwas masked by anAttributeErrorinstead.STLSeriesTransformer/MSTLSeriesTransformernever used Numba bydefault:
_resolve_use_numba_localreturnedbool(self.use_numba),which silently turns the documented default
use_numba=None("auto: useNumba if available, otherwise NumPy") into
False. So the defaultconfiguration always took the slower NumPy path, even with Numba
installed. The existing parity test only passed because both backends are
numerically equivalent by design — it never checked which one actually
ran. Fixed so
NonestaysNoneand defers to the existingNumba-availability auto-detection. A follow-up issue (#) tracks a
bigger question this surfaced — whether Numba's optional-import fallback
in
_stl.pystill makes sense given it's a core dependency — which is outof scope here;
_stl.py's own test coverage is intentionally leftuntouched in this PR pending that decision.
Dead/unreachable code removed
_sliding_windowhelper in_clasp.py(not called anywhere).elif/exact-complement branches in_yeojohnson.py(
elif lmbda == 0afterif lmbda != 0, etc.) and_clasp.py's_check_scoring_metric— these conditions can never be false given theprior branch, so simplified to
else.elsebranch in_pla.py's SWAB loop: analytically,current_data_pointcan never exceedlen(X)since_best_lineneverreturns more elements than remain in the series, so the "data exhausted"
branch was dead.
Coverage
Brought the following modules to ~96–100% statement coverage (measured with
NUMBA_DISABLE_JIT=1, since coverage.py cannot trace into compiled@njitcode):
_collection_wrapper.py,_boxcox.py,_yeojohnson.py,_scaled_logit.py,base.py,compose/_pipeline.py,compose/_identity.py,smoothing/_rms.py,_diff.py,_log.py,_warping.py,_dobin.py,_bkfilter.py,_pla.py,_clasp.py,_mstl.py. Added two new test files(
test_collection_wrapper.py,test_log.py) for previously untestedtransformers.
A few branches are intentionally left uncovered: defensive
RuntimeErrorguards and generic
roc_auc-style edge cases that are unreachable given howthey're actually invoked in this codebase, plus code gated behind the
statsmodels/stumpysoft dependencies (not installed in this environment)._stl.pyitself is excluded from the coverage pass for now (see the Numbabug note above).