Skip to content

Fix incorrect return type annotations in darts.utils.statistics - #3185

Merged
dennisbader merged 4 commits into
unit8co:masterfrom
AlejandroCoronadoN:fix-statistics-return-annotations
Sep 18, 2026
Merged

dennisbader merged 4 commits into
unit8co:masterfrom
AlejandroCoronadoN:fix-statistics-return-annotations

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

Three functions in darts/utils/statistics.py have return type annotations that do not match what they actually return:

  • stationarity_test_kpss is annotated -> set but returns a tuple (it wraps statsmodels.tsa.stattools.kpss).
  • stationarity_test_adf is annotated -> set but returns a tuple (it wraps adfuller).
  • granger_causality_tests is annotated -> None but returns a dict (it wraps grangercausalitytests); its own docstring already says it returns a Dict.

The docstrings and the existing tests already treat these as tuples/dict (for example stationarity_test_kpss(series)[1]), so the annotations are just wrong and mislead type checkers and IDEs. This fixes the annotations to match the real return values and adds a small regression test.

@codecov

codecov Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.06%. Comparing base (4ce4d4b) to head (77e065f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3185   +/-   ##
=======================================
  Coverage   97.06%   97.06%           
=======================================
  Files         169      169           
  Lines       18898    18898           
=======================================
  Hits        18343    18343           
  Misses        555      555           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlejandroCoronadoN
AlejandroCoronadoN force-pushed the fix-statistics-return-annotations branch from c77c729 to 6c1b008 Compare August 21, 2026 12:40

@dennisbader dennisbader left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks a lot for the PR and fix @AlejandroCoronadoN 🚀

I removed the tests (not really necessary to check the return type) and slightly adapted the changelog entry.

I'll merge once all tests have passed.

@dennisbader
dennisbader merged commit 484387a into unit8co:master Sep 18, 2026
9 checks passed
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.

2 participants