Fix trend anomaly for window lengths not divisible by 5#91
Open
tomlouisklein wants to merge 1 commit into
Open
Fix trend anomaly for window lengths not divisible by 5#91tomlouisklein wants to merge 1 commit into
tomlouisklein wants to merge 1 commit into
Conversation
…always sum to exactly length. Truncating int(length * 0.2) and int(length * 0.8) independently loses one sample whenever length is not a multiple of 5, which made the amplitude envelope one sample shorter than the trend time series and broke the *= broadcast.
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.
While doing some experiments for my master thesis, I noticed a tiny bug in how trend anomalies are created.
There is a 20/80 split between
transition_lengthandplateau_length. Truncatingint(length * 0.2)andint(length * 0.8)independently loses one sample wheneverlengthis not a multiple of 5, which made the amplitude envelope one sample shorter than the trend time series and broke the*=broadcast. An easy solution is to derive theplateau_lengthfrom thetransition_lengthso that the two always sum to exactlylength.I ran the pre-commit hooks against both files (black, flake8, mypy, whitespace) — they pass. The only mypy warning is a pre-existing one in gutenTAG/config/validator.py, which I didn't touch.
I also added a test file
tests/test_generator/test_trend_anomaly_length.py, which covers every residue mod 5 and fails for the old code and passes for the fix.