Skip to content

Feat/rust for percentiles#156

Open
Oisin-M wants to merge 20 commits intodevelopfrom
feat/rust_for_percentiles
Open

Feat/rust for percentiles#156
Oisin-M wants to merge 20 commits intodevelopfrom
feat/rust_for_percentiles

Conversation

@Oisin-M
Copy link
Collaborator

@Oisin-M Oisin-M commented Oct 31, 2025

Description

Tackles part of #147. Close #68.

Now have

ekh.upstream.percentile(river_network, field, p)
ekh.upstream.array.percentile(river_network, field, p)
ekh.catchments.percentile(river_network, field, p)
ekh.catchments.array.percentile(river_network, field, p)

Will not support weights in first version, nor will we support downstream.percentile. Switching return_type gridded or masked works out of the box.

Median is percentile with p=0.5, so this is trivial to add if we want a separate function.

Tasks:

  • rust-accelerated percentile function (full field)
  • (later PR) support weights
  • (Optional) nan support
  • ekh.upstream.percentile
  • (later PR) ekh.downstream.percentile
  • ekh.catchments.percentile
  • assert using numpy
  • array type handling (autoconvert to float64)
  • ensure percentile requested is in [0,1].
  • docs
  • code clean-up
  • tests

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.24%. Comparing base (1ae44bd) to head (e15acf7).
⚠️ Report is 13 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #156      +/-   ##
===========================================
+ Coverage    92.50%   94.24%   +1.74%     
===========================================
  Files            8       20      +12     
  Lines          200      278      +78     
===========================================
+ Hits           185      262      +77     
- Misses          15       16       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@Oisin-M Oisin-M marked this pull request as ready for review October 31, 2025 13:44
@Oisin-M Oisin-M mentioned this pull request Oct 31, 2025
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.

Add percentile metric

2 participants