Repository navigation
fix(ceemdan): fix pure-IMF local mean, constant/zero-noise guards, and kwarg leakage - #195
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes four correctness bugs in
PyEMD/CEEMDAN.py:local_mean += imfs[-1] / self.trialsassumedimfs[-1]was always the residue ofself.emd(res, T, max_imf=1). Whenresis already a pure IMF (residueEMD.emdomits the zero residue from its return array, causingimfs[-1]to add the IMF itself instead of0(zeroing out the extracted cIMF). Now usesself.EMD.get_imfs_and_residue()(withimfs[-1]fallback for customext_EMDobjects without it).NaNcrash: Guardscale_s = np.std(S)whenscale_s == 0, returning[S.copy()]with zero residue instead of dividing by zero._decompose_noise()and_trial_update()when a decomposed noise realization has 0 IMFs or zero standard deviation (noise_scale=0.0), preventingIndexErrorandZeroDivisionError/NaN.EMD: Pop CEEMDAN-only kwargs (range_thr,total_power_thr,noise_scale,beta_progress,seed,noise_kind,max_imf,processes) before instantiatingEMD(**kwargs)so tuning CEEMDAN stopping thresholds does not unintentionally alter the innerEMDthresholds.Tests
Added 4 regression tests in
PyEMD/tests/test_ceemdan.py:test_ceemdan_constant_signal_no_nantest_ceemdan_zero_noise_scale_no_nantest_ceemdan_kwargs_do_not_leak_thresholds_to_inner_emdtest_ceemdan_pure_imf_local_mean_is_zeroAll 124 unit tests pass (
python -m PyEMD.tests.test_all), andisort+black==25.11.0pass.Benchmark Comparison (vs
masterbaseline)Ran
perf_test/perf_test_comprehensive.py --test ceemdanand--quick:CEEMDAN(--test ceemdan)CEEMDAN(--test ceemdan)CEEMDAN(--test ceemdan)CEEMDAN(--quick)CEEMDAN(--quick)No performance regressions across CEEMDAN benchmarks.