Skip to content

Conversation

@mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Dec 1, 2025

I'd like to move towards addressing #23272, but we need an integer-specific implementation of hist for this to work, as the large-integer timestamps in us and ns work pretty poorly when converted to floats in the current histogram implementation. This refactor is intended to allow for easier paths for more dtype-specific histogram implementations if desired. The base algorithms remain the same, but there is a slightly better distinction between variable-width histograms (i.e. user-supplied edges) and uniform-width histograms (bin-count supplied).

I've moved the cast of the series and bins to the IR to make the implementation a little cleaner by the time we reach it. If we move to temporal histograms, we can easily coerce the arguments in the IR as well so that supplied bins match the series.

At some point soon, I would like to rename bins to edges (open issue #23335), since the parameter actually refers to the bin edges, not the bins themselves. Internally we now use edges as it's much clearer what it refers to.

No changes to tests, as they are fairly comprehensive.

@github-actions github-actions bot added internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars labels Dec 1, 2025
@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 96.98276% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.61%. Comparing base (dc6f1ad) to head (fb3ed94).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-ops/src/chunked_array/hist.rs 97.39% 5 Missing ⚠️
...ars-plan/src/plans/conversion/type_coercion/mod.rs 95.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25574      +/-   ##
==========================================
- Coverage   79.71%   79.61%   -0.11%     
==========================================
  Files        1729     1729              
  Lines      239702   239771      +69     
  Branches     3038     3038              
==========================================
- Hits       191078   190891     -187     
- Misses      47841    48097     +256     
  Partials      783      783              

☔ 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.

@mcrumiller mcrumiller marked this pull request as ready for review December 2, 2025 02:20
@mcrumiller mcrumiller changed the title refactor: Refactor hist refactor(rust): Refactor hist Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant