Namespace homogenisation#2
Open
matulni wants to merge 4 commits into
Open
Conversation
matulni
added a commit
to TeamGraphix/graphix
that referenced
this pull request
Jul 21, 2026
This PR introduces a homogeneous and pythonic naming convention for transformation methods and accessors. ## Transformation methods We fix the following convention: - `.to_<object>` when the transformation can only return an `object` or raise an exception. If `object` corresponds to an existing class, we use the name of the class without underscores and small case. Ex.: `to_opengraph`, `to_causalflow`, `to_xzcorrections`, etc. Non-exhaustive list of method names (unless specified, the method name remained the same in the commit): - `Pattern.to_opengraph` (formerly `Pattern.extract_opengraph`) - `Pattern.to_xzcorrections` (formerly `Pattern.extract_xzcorrections`) - `Pattern.to_qasm3` - `Pattern.to_causalflow` (formerly `Pattern.extract_causal_flow`) - `Pattern.to_gflow` (formerly `Pattern.extract_gflow`) - `Pattern.to_pauliflow` (formerly `Pattern.extract_pauli_flow`) - `StandardizedPattern.to_pattern` - `StandardizedPattern.to_space_optimal_pattern` - `StandardizedPattern.to_opengraph` (formerly `StandardizedPattern.extract_opengraph`) - `StandardizedPattern.to_xzcorrections` (formerly `StandardizedPattern.extract_xzcorrections`) - `XZCorrections.to_pattern` - `XZCorrections.to_causalflow` (formerly `XZCorrections.to_causal_flow`) - `XZCorrections.to_gflow` - `XZCorrections.to_pauliflow` (formerly `XZCorrections.to_pauli_flow`) - `XZCorrections.to_dag` (formerly `XZCorrections.extract_dag`) - `PauliFlow.to_xzcorrections` (formerly `PauliFlow.to_corrections`) - `GFlow.to_xzcorrections` (formerly `GFlow.to_corrections`) - `CausalFlow.to_xzcorrections` (formerly `CausalFlow.to_corrections`) - `ExtractionResult.to_circuit` - `PauliString.to_tableau` - `CliffordMap.to_tableau` - `<...>.to_bloch` - `AbstractMeasurement.to_plane_or_axis` - `AbstractPlanarMeasurement.to_plane` - `Measurement.to_pauli_or_bloch` - `<...>.to_ascii` - `<...>.to_unicode` - `<...>.to_latex` - `State.to_statevector_numpy` (formerly `State.to_statevector`) - `State.to_densitymatrix_numpy` (formerly `State.to_densitymatrix`) - `Opengraph.to_pattern` - `Opengraph.to_causal_flow` (formerly `Opengraph.extract_causal_flow`) - `Opengraph.to_gflow` (formerly `Opengraph.extract_gflow`) - `Opengraph.to_pauli_flow` (formerly `Opengraph.extract_pauli_flow`) - `Opengraph.to_circuit` (formerly `OpenGraph.extract_circuit`) - `Noise.to_krauschannel` (formerly `Noise.to_kraus_channel`) - `<...>.to_standardizedpattern` (formerly `<...>.to_standardized_pattern`) - `.to_<object>_or_none` when the transformation can fail returning `None`, even if the initial object is well-formed: - `Opengraph.to_causalflow_or_none` (formerly `Opengraph.find_causal_flow`) - `Opengraph.to_gflow_or_none` (formerly `Opengraph.find_gflow`) - `Opengraph.to_pauliflow_or_none` (formerly `Opengraph.find_pauli_flow`) - `Measurement.to_pauli_or_none` (formerly `Measurement.try_to_pauli`) - `.from_<object>` for constructors that can only return an `object` or raise an exception. - `<...>.from_standardizedpattern` (formerly `<...>.from_standardized_pattern`) - `.from_<object>_or_none` for constructors that can fail returning `None` - `PauliFlow.from_correctionmatrix_or_none` (formerly `PauliFlow.try_from_correction_matrix`) - `ComplexUnit.from_or_none` (formerly `ComplexUnit.try_from`) Exception to this naming convention: - `Circuit.transpile` Reason: returns a `TranspileResult` and established word in the community. - `Pattern.simulate`. Reason: established word in the community. - `PauliFlow.extract_circuit`. Reason: returns an `ExtractionResult` and established word in the community. ## Accessor methods For accessor methods which don't return an "MBQC class" but rather a "Python object" we use plain nouns, even if the method is not a property. This follows the convention used by many python libraries, like numpy or networkx. List method names (unless specified, the method name remained the same in the commit): - `Pattern.node_mapping` - `Pattern.signals` (formerly `Pattern.extract_signals`) - `Pattern.partial_order_layers` (formerly `Pattern.extract_partial_order_layers`) - `Pattern.measurement_commands` (formerly `Pattern.extract_measurement_commands`). - `Pattern.max_degree` (formerly `Pattern.compute_max_degree`). - `Pattern.graph` (formerly `Pattern.extract_graph`). - `Pattern.nodes` (formerly `Pattern.extract_nodes`). - `Pattern.isolated_nodes` (formerly `Pattern.extract_isolated_nodes`). - `Pattern.clifford_commands` (formerly `Pattern.extract_clifford`). - `Pattern.connected_nodes` - `Pattern.correction_commands` - `Pattern.max_space` - `Pattern.space_list` - `Opengraph.neighbors` - `Opengraph.odd_neighbors` - `PauliFlow.node_measurement_label` - `PauliFlow.extraction_pauli_strings` (this is already a cached property) - `MatGF2.rank` (formerly `MatGF2.compute_rank`) ## Consistent class naming Class `Statevec` was renamed as `Statevector` to match `StatevectorBackend` and transformation method conventions. ## Reverse dependencies Changes were made in the following repositories: - `graphix-pyzx`TeamGraphix/graphix-pyzx#2 - `graphix-stim-compiler` TeamGraphix/graphix-stim-compiler#1 - `graphix-stim-backend` TeamGraphix/graphix-stim-backend#2 - `graphix-mqtbench` - `graphix-ibmq` TeamGraphix/graphix-ibmq#25 - `veriphix` qat-inria/veriphix#25 Reverse dependencies in the `nox.py` was changed accordingly. See accompanying PRs in these repositories.
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.
See TeamGraphix/graphix#557 in Graphix repository