[BUG] Fix HidalgoSegmenter IndexError with empty sampling (Fixes #3168)#3169
Conversation
Thank you for contributing to
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical IndexError bug in HidalgoSegmenter that occurs when incompatible burn_in and sampling_rate parameters result in zero valid samples after filtering. The fix adds proper validation and error handling to detect and report this configuration issue with a helpful error message.
Key changes:
- Added empty sample detection with early continue for individual replicas
- Implemented validation to ensure at least one replica produces valid samples
- Corrected Pi normalization to use actual sample count instead of the number of manifolds (K)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test_hidalgo_fix.py | New test file with three test cases covering empty sampling error, valid configuration, and boundary cases |
| aeon/segmentation/_hidalgo.py | Bug fix implementation including empty sample handling, validation error, and Pi normalization correction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
046b5d3 to
0e7b743
Compare
…-toolkit#3150) - Handle case where no Gibbs samples survive burn-in and sampling_rate filtering - Initialize bestsampling as None to detect empty filtering result - Skip replicas that produce empty idx arrays to continue searching - Validate that at least one valid sample exists before accessing array - Raise informative ValueError with guidance on parameter adjustment - Update Pi normalization to use actual sample count instead of idx length
3dfb250 to
067cca9
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Sorry for only getting around to this now. We had 3 PRs on this and 2 issues I believe, but going with this. Made some changes to speed up and get this tidied quicker, including moving the tests. |
TonyBagnall
left a comment
There was a problem hiding this comment.
thank you for this @samay2504 sorry it took so long to get in!
Fixes #3168
Fixes #3150
Problem
HidalgoSegmenter crashes with IndexError: too many indices for array when configured with incompatible burn_in and sampling_rate parameters that result in zero samples passing the filtering criteria.
Root Cause
The _fit() method filters samples using:
Solution: