feat(py_qubed): ergonomic Python API with immutable ops and new surface#108
Draft
HCookie wants to merge 1 commit into
Draft
feat(py_qubed): ergonomic Python API with immutable ops and new surface#108HCookie wants to merge 1 commit into
HCookie wants to merge 1 commit into
Conversation
Breaking changes: - Class renamed from PyQube to Qube on the Python side - drop() and squeeze() now return a new Qube instead of mutating - to_datacubes() and all_unique_dim_coords() return native Python types - from_arena_json() now accepts str | dict New API surface: - Qube.empty(), Qube.is_empty() - Qube.from_json() / to_json() (nested key=value format) - Qube.from_tree_json() / to_tree_json() - axes() (alias for all_unique_dim_coords) - dimensions() returns set[str] - __or__ operator (a | b) for non-mutating merge - __copy__ / __deepcopy__ support - from_datacube preserves Python dict insertion order - Datacube dicts accept list, int, float values (not just strings) Also includes all Rust-level fixes required for the Python API: - Coordinate intersection safety and leading-zero consistency - Merge dimension translation map for cross-Qube safety - Tree JSON serialisation format - Deterministic from_datacube ordering Tests updated for new API, docs rewritten.
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
Overhauls the Python API for ergonomics, safety, and Pythonic conventions. This is the largest PR in the split and includes all underlying Rust changes needed to support the new surface.
Breaking changes
PyQubeclass nameQubedrop()mutates in placeQubesqueeze()mutates in placeQubeto_datacubes()returns stringsfrom_arena_json(str)from_arena_json(str | dict)New API surface
Qube.empty(),Qube.is_empty()Qube.from_json()/to_json()(nested key=value format)Qube.from_tree_json()/to_tree_json()axes()(alias forall_unique_dim_coords)dimensions()returnsset[str]__or__operator (a | b) for non-mutating merge__copy__/__deepcopy__supportfrom_datacubepreserves Python dict insertion order as default dimension orderinglist,int,floatvalues (not just strings)Included Rust changes
This PR bundles the Rust-level fixes that the Python API depends on:
Tests & docs
Qubeclass name and native-type returns|operator, immutabledrop/squeeze,axes(),dimensions()test_qubed_initialisation.pyforQube.empty()docs/src/python/py_qubed.mdrewritten for new APIPart of the split from #102. Independently mergeable (includes all dependencies).