Skip to content

Fix trend anomaly for window lengths not divisible by 5#91

Open
tomlouisklein wants to merge 1 commit into
TimeEval:mainfrom
tomlouisklein:fix/trend_envelope_length
Open

Fix trend anomaly for window lengths not divisible by 5#91
tomlouisklein wants to merge 1 commit into
TimeEval:mainfrom
tomlouisklein:fix/trend_envelope_length

Conversation

@tomlouisklein

Copy link
Copy Markdown

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_length andplateau_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. An easy solution is to derive the plateau_length from the transition_length so that the two always sum to exactly length.

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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant