Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Streak lengths #100

Merged
merged 5 commits into from
Oct 27, 2023
Merged

Conversation

TomBurdge
Copy link
Contributor

Written tests for the streak length stats.

Following my questions to @abstractqqq in the Unit Test Tracker I have implemented tests and small changes to streak length stats.

I made some small changes to streaks function:

  • Fix a bug for mode - when df is bi-modal it will return both modes in an unpredictable order. The function has clearly been written to return the lowest mode, so I have implemented it as such with a sort.
  • Previously the function would fail for no streaks. Handling for this implemented per aforementioned discussion in issue 70.

Prior to this,there is an issue where the series/expression is bi-modal.
Which modal value appears first is indeterminate.
As a result, results are not idempotent.
This fix sorts to generate idempotent mode results.
Have inferred the intended behaviour as taking the smallest modal value.
if input series: dictionary with Nones and 0 for min
empty df
@vercel
Copy link

vercel bot commented Oct 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
functime-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 27, 2023 4:19am

@@ -1668,25 +1688,25 @@ def streak_length_stats(x: TIME_SERIES_T, above: bool, threshold: float) -> MAP_
y = y.filter(y.struct.field("values")).struct.field("lengths")
if isinstance(x, pl.Series):
return {
"min": y.min(),
"min": y.min() or 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know Python supports this lol 👍

@topher-lo topher-lo added the tests Testing label Oct 26, 2023
@topher-lo topher-lo changed the title Test streak length stats test: Streak lengths Oct 27, 2023
@topher-lo topher-lo merged commit 4152783 into functime-org:main Oct 27, 2023
5 checks passed
topher-lo pushed a commit that referenced this pull request Dec 19, 2023
Co-authored-by: TQQQ <72534736+abstractqqq@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants