Replies: 1 comment
-
|
@thierry-martinez : use PauliFlow.try_from_correction_matrix -- > PauliFlow.from_correction_matrix |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Current naming for transformation methods is not consistent throught the codebase, mostly because there isn't a clear documented convention.
We suggest fixing the following convention (unless specified, the method name remains the same):
.to_<object_name>when the transformation is always well defined (i.e., it cannot fail assuming runnable and well-formed objects):Pattern.to_opengraph(formerlyPattern.extract_opengraph)Pattern.to_xzcorrections(formerlyPattern.extract_xzcorrections)Pattern.to_qasm3StandardizedPattern.to_patternStandardizedPattern.to_space_optimal_patternStandardized.to_opengraph(formerlyStandardized.extract_opengraph)StandardizedPattern.to_xzcorrections(formerlyStandardizedPattern.extract_xzcorrections)XZCorrections.to_patternPauliFlow.to_xzcorrections(formerlyPauliFlow.to_corrections)PauliFlow.to_circuit(formelyPauliFlow.extract_circuit)ExtractionResultinstead of aCircuit, and in the literature this procedure is known as "circuit extraction".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_statevectorState.to_densitymatrix.extract_<object_name>when the transformation can fail raising an exception, even if the initial object is well-formed:Pattern.extract_causal_flowPattern.extract_gflowOpengraph.extract_pattern(formerlyOpengraph.to_pattern)Opengraph.extract_causal_flowOpengraph.extract_gflowOpengraph.extract_pauli_flowOpengraph.extract_circuitXZCorrections.extract_causal_flow(formerlyXZCorrections.to_causal_flow)XZCorrections.extract_gflow(formerlyXZCorrections.to_gflow).find_<object_name>when the transformation can fail returningNone, even if the initial object is well-formed:Opengraph.find_causal_flowOpengraph.find_gflowOpengraph.find_pauli_flowThe only exception to this naming convention is:
Circuit.transpile, andPattern.simulatesince these are established words in the community.Further, for "getter methods" which don't return an "MBQC class" but rather a "Python object" we suggest using plain nouns, even if the method is not a property (unless specified, the method name remains the same):
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.connect_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)Questions to discuss
Q1: Is this the naming convention we want ?
I personally prefer
.try_to_<object>instead of.extract_<object>, and.to_<object>_or_noneinstead of.find_<object>. Not sure if it's not too pythonic, but it's more self-explanatory than the convention above. Also, this would be more consistent with currentPauliFlow.try_from_correction_matrix, and withMeasurement.to_pauli_or_bloch. ThenMeasurement.try_to_paulishould becomeMeasurement.to_pauli_or_none.Q2: Are we missing any methods in the public API?
I went through the main modules but I may have missed something.
Q3: How to best split this PR?
A priori, we just need to do a search and replace, but the refactoring will have an important impact on most (if not all) the reverse dependencies. This can become very tedious to review and merge. Should we wait until having most PRs merged across dependencies before starting the refactoring? How can we split the PR?
Beta Was this translation helpful? Give feedback.
All reactions