Namespace homogenisation #557
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #557 +/- ##
=======================================
Coverage 90.58% 90.58%
=======================================
Files 49 49
Lines 7481 7481
=======================================
Hits 6777 6777
Misses 704 704 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This is a great improvement, thanks! | If object corresponds to an existing class, we use the name of the class without underscores and small case. There are still some exceptions:
If we introduce a dedicated class |
Thanks. I'm doubtful. Indeed, it would be more consistent to change them, but not sure if it hinders code readability.
Another exception/inconsistency is that we use The backend naming is also somewhat inconsistent: |
thierry-martinez
left a comment
There was a problem hiding this comment.
LGTM! Thanks for all these changes.
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 anobjector raise an exception. Ifobjectcorresponds 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(formerlyPattern.extract_opengraph)Pattern.to_xzcorrections(formerlyPattern.extract_xzcorrections)Pattern.to_qasm3Pattern.to_causalflow(formerlyPattern.extract_causal_flow)Pattern.to_gflow(formerlyPattern.extract_gflow)Pattern.to_pauliflow(formerlyPattern.extract_pauli_flow)StandardizedPattern.to_patternStandardizedPattern.to_space_optimal_patternStandardizedPattern.to_opengraph(formerlyStandardizedPattern.extract_opengraph)StandardizedPattern.to_xzcorrections(formerlyStandardizedPattern.extract_xzcorrections)XZCorrections.to_patternXZCorrections.to_causalflow(formerlyXZCorrections.to_causal_flow)XZCorrections.to_gflowXZCorrections.to_pauliflow(formerlyXZCorrections.to_pauli_flow)PauliFlow.to_xzcorrections(formerlyPauliFlow.to_corrections)GFlow.to_xzcorrections(formerlyGFlow.to_corrections)CausalFlow.to_xzcorrections(formerlyCausalFlow.to_corrections)ExtractionResult.to_circuitPauliString.to_tableauCliffordMap.to_tableau<...>.to_blochAbstractMeasurement.to_plane_or_axisAbstractPlanarMeasurement.to_planeMeasurement.to_pauli_or_bloch<...>.to_ascii<...>.to_unicode<...>.to_latexState.to_statevector_numpy(formerlyState.to_statevector)State.to_densitymatrix_numpy(formerlyState.to_densitymatrix)Opengraph.to_patternOpengraph.to_causal_flow(formerlyOpengraph.extract_causal_flow)Opengraph.to_gflow(formerlyOpengraph.extract_gflow)Opengraph.to_pauli_flow(formerlyOpengraph.extract_pauli_flow)Opengraph.to_circuit(formerlyOpenGraph.extract_circuit)Noise.to_krauschannel(formerlyNoise.to_kraus_channel)<...>.to_standardizedpattern(formerly<...>.to_standardized_pattern).to_<object>_or_nonewhen the transformation can fail returningNone, even if the initial object is well-formed:Opengraph.to_causalflow_or_none(formerlyOpengraph.find_causal_flow)Opengraph.to_gflow_or_none(formerlyOpengraph.find_gflow)Opengraph.to_pauliflow_or_none(formerlyOpengraph.find_pauli_flow)Measurement.to_pauli_or_none(formerlyMeasurement.try_to_pauli).from_<object>for constructors that can only return anobjector raise an exception.<...>.from_standardizedpattern(formerly<...>.from_standardized_pattern).from_<object>_or_nonefor constructors that can fail returningNonePauliFlow.from_correctionmatrix_or_none(formerlyPauliFlow.try_from_correction_matrix)ComplexUnit.from_or_none(formerlyComplexUnit.try_from)Exception to this naming convention:
Circuit.transpileReason: returns aTranspileResultand established word in the community.Pattern.simulate. Reason: established word in the community.PauliFlow.extract_circuit. Reason: returns anExtractionResultand 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_mappingPattern.signals(formerlyPattern.extract_signals)Pattern.partial_order_layers(formerlyPattern.extract_partial_order_layers)Pattern.measurement_commands(formerlyPattern.extract_measurement_commands).Pattern.max_degree(formerlyPattern.compute_max_degree).Pattern.graph(formerlyPattern.extract_graph).Pattern.nodes(formerlyPattern.extract_nodes).Pattern.isolated_nodes(formerlyPattern.extract_isolated_nodes).Pattern.clifford_commands(formerlyPattern.extract_clifford).Pattern.connected_nodesPattern.correction_commandsPattern.max_spacePattern.space_listOpengraph.neighborsOpengraph.odd_neighborsXZCorrections.dag(formerlyXZCorrections.extract_dag)PauliFlow.node_measurement_labelPauliFlow.extraction_pauli_strings(this is already a cached property)MatGF2.rank(formerlyMatGF2.compute_rank)Consistent class naming
Class
Statevecwas renamed asStatevectorto matchStatevectorBackendand transformation method conventions.Reverse dependencies
Changes were made in the following repositories:
graphix-pyzxNamespace homogenisation graphix-pyzx#2graphix-stim-compilerNamespace homogenisation graphix-stim-compiler#1graphix-stim-backendNamespace homogenisation graphix-stim-backend#2graphix-mqtbenchgraphix-ibmqNamespace homogenisation graphix-ibmq#25veriphixNamespace homogenisation qat-inria/veriphix#25Reverse dependencies in the
nox.pywas changed accordingly. See accompanying PRs in these repositories.