Add typed Polars quantity frames#20
Merged
Merged
Conversation
Evaluation prototype for IMPROVEMENT.md 1.1: UnitDType (pl.BaseExtension, unit string normalized through the registry as dtype metadata) plus with_units/units_of/quantities/dataframe helpers. Plain polars I/O round-trips the dtype; unit algebra stays in Quantity, constructed from unit-typed columns. Tests pin the round-trip and refusal semantics since the upstream extension-type API is unstable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011o88ZV5hHQHYRMDVWSzxu1
An extension-typed input column (e.g. the encomp.polars unit dtype) panicked inside the plugin's FFI field import: the plugin build lacked polars' dtype-extension feature, so from_arrow_field hit the unsupported-dtype panic arm before any plugin code ran. Enable dtype-extension (the plugin's own registry loads unknown extension types as generic, never as bare storage, so the dtype arrives intact) and validate inputs in the output-dtype callbacks and compute entrypoints: an extension-typed input now fails at schema-resolution time with an actionable message naming the input and suggesting `.ext.storage()` after SI conversion. Silently using the storage values was not an option -- it could treat e.g. bar as Pa. The Cargo.lock growth is the feature's transitive polars-expr/polars-dtype tree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011o88ZV5hHQHYRMDVWSzxu1
An "encomp.unit" extension-typed input whose unit is already the SI unit CoolProp expects now passes straight through the plugin (storage values used as-is); any other unit is refused at schema-resolution time with both units named. No unit table is duplicated anywhere: the wrappers derive the expected unit from CoolProp's own parameter metadata (get_parameter_information) for fluid inputs and from the existing HumidAir.get_coolprop_unit mapping for humid air, normalized through the registry -- the same canonicalization the unit dtype applies to its metadata, so the plugin's check is plain string equality. The Float32 output rule looks through the extension dtype to its storage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011o88ZV5hHQHYRMDVWSzxu1
…tting
End-to-end review of the SI-match acceptance found one real defect:
canonicalization went through str(Unit(...)), which follows the
process-wide display format. After set_quantity_format("siunitx"), the
dtype metadata would be written as LaTeX and the plugin's unit
comparison would drift with a display setting. Both sides now use
encomp.polars.canonical_unit_string (fixed "~P": "m³/h", "°C" --
identical to the default rendering, so nothing already written changes).
Regression tests pin the metadata rendering and the plugin match under
a non-default display format, plus a Parquet-scan end-to-end through
the plugin on both engines.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011o88ZV5hHQHYRMDVWSzxu1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation