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

fix: Infer reshape dims when determining schema #18923

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

coastalwhite
Copy link
Collaborator

This fixes the reshape function to properly infer dimensions in the schema.

I did this by adding a "zero-cost" ReshapeDimension enum that can either be Specified(u64) or Infer. This also makes the reshaping behavior more consistent as now all negative values are always assumed to be Infer.

During this work, I saw an unneeded allocation in reshape_array and removed it.

Fixes #18879.

This fixes the `reshape` function to properly infer dimensions in the schema.

I did this by adding a "zero-cost" `ReshapeDimension` enum that can either be
`Specified(u64)` or `Infer`. This also makes the reshaping behavior more
consistent as now all negative values are always assumed to be `Infer`.

During this work, I saw an unneeded allocation in `reshape_array` and removed
it.

Fixes pola-rs#18879.
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Sep 25, 2024
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 80.33708% with 35 lines in your changes missing coverage. Please review.

Project coverage is 79.87%. Comparing base (d3f8a5c) to head (0d51ff8).
Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
crates/polars-core/src/datatypes/reshape.rs 65.45% 19 Missing ⚠️
crates/polars-plan/src/dsl/function_expr/schema.rs 70.37% 8 Missing ⚠️
crates/polars-core/src/series/ops/reshape.rs 92.30% 4 Missing ⚠️
crates/polars-plan/src/dsl/function_expr/mod.rs 33.33% 2 Missing ⚠️
crates/polars-plan/src/dsl/function_expr/list.rs 75.00% 1 Missing ⚠️
.../polars-python/src/lazyframe/visitor/expr_nodes.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18923      +/-   ##
==========================================
- Coverage   79.89%   79.87%   -0.02%     
==========================================
  Files        1520     1522       +2     
  Lines      206552   206943     +391     
  Branches     2906     2906              
==========================================
+ Hits       165020   165299     +279     
- Misses      40984    41096     +112     
  Partials      548      548              

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

@ritchie46 ritchie46 merged commit aec911f into pola-rs:main Sep 26, 2024
25 of 26 checks passed
@coastalwhite coastalwhite deleted the fixes/reshape-panic branch September 26, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reshape + .arr.to_struct() capacity overflow PanicException
2 participants