fix: trend detection for normalised time series#79
fix: trend detection for normalised time series#79ChrisMarsden833 wants to merge 8 commits intodevelopfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Looks great. Thanks so much for this. I left some nitpick comments which shouldnt take much work. What might take some time though is adding tests.
For this change we will need to add 2 tests.
Test 1
Test for the main focus of this commit, your [0,1] signal.
- Could make a new module to add tests to called something like
tests/tests_normalised_trends - You can reference your test data in a local csv somewhere under tests. E.g. save the csv
tests/tests_normalised_trends/normalised_data.csvand have a test file that calls ittests/test_normalised_trends.py - You can follow the similar pattern of most tests, e.g.
test_core_cases.py: line 18. The idea is to load the signal, detect trends, and then assess that the detected segments are as expected.
Test 2
Test for covering the lines of debug statements.
- A bit silly, but there's hard enforced rules to maintain the maximized code coverage to avoid missing any new edge cases.
- This test could work with any data really .... To make things simple could use same test data above and just make sure that once debug True is enabled that it runs plt show calls from within process_trends().
- You can refer to
test_plot_pytrendy_edgecases.py: line 114on how to do this with monkey patching. By setting detect trends plot=False, debug=True you should expect plt show to be hit from the debug True lines.
|
Just realised there are some other nitpick changes to be resolved here, will resolve these too. |
…code coverage in abrupt_shaving.py.
|
I think I've addressed everything, see what you think. |
|
📚 Docs preview deployed! Your docs preview is available at: https://russellsb.github.io/pytrendy/pr-79/
|
|
I've made the suggested changes and removed the nitpicks. I've left in a pair of tests that check that debug mode doesn't affect the actual results, which feels particuarly important to include. |
Potential fix for 77. Needs review.
Copilot summary:
This pull request introduces a debug mode for the trend detection pipeline and refines the method for detecting trends in time series data. The debug mode provides additional plots and print statements for developers, while the trend detection logic is improved by using a data-driven threshold based on the interquartile range (IQR) of the signal. The most important changes are grouped below:
Debug Mode Enhancements:
debugparameter to thedetect_trendsandprocess_signalsfunctions, allowing developers to enable detailed debugging output, including additional plots and print statements. [1] [2] [3] [4] [5]process_signalsthat visualizes intermediate signal processing steps whendebug=True, aiding in development and troubleshooting.Trend Detection Improvements:
THRESHOLD_SMOOTH) from a fixed value to a fraction of the signal's IQR, making the detection logic more adaptive to the data's variability. [1] [2]