Skip to content

Commit

Permalink
Simplify python class construction
Browse files Browse the repository at this point in the history
Since this PR was first written the split between the python side and
rust side of the CommutationChecker class has changed so that there are
no longer separate classes anymore. The implementations are unified and
the python space class just wraps an inner rust object. However, the
construction of the CommutationAnalysis pass was still written assuming
there was the possibility to get either a rust or Python object. This
commit fixes this and the type change on the `comm_checker` attribute by
removing the unnecessary logic.
  • Loading branch information
mtreinish committed Sep 4, 2024
1 parent 7073570 commit 68f4f4b
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""Analysis pass to find commutation relations between DAG nodes."""

from qiskit.circuit.commutation_library import SessionCommutationChecker as scc
from qiskit.circuit.commutation_checker import CommutationChecker as PyCommutationChecker
from qiskit.transpiler.basepasses import AnalysisPass
from qiskit._accelerate.commutation_analysis import analyze_commutations

Expand All @@ -33,12 +32,6 @@ def __init__(self, *, _commutation_checker=None):
if _commutation_checker is None:
_commutation_checker = scc

if isinstance(_commutation_checker, PyCommutationChecker):
# If an instance of the to-be deprecated Python implementation of the CommutationChecker
# is passed, defer to the internally held Rust implementation instead. This is needed
# as the ``analyze_commutations`` function expects the Rust implementation.
_commutation_checker = _commutation_checker.cc

self.comm_checker = _commutation_checker

def run(self, dag):
Expand All @@ -48,4 +41,4 @@ def run(self, dag):
into the ``property_set``.
"""
# Initiate the commutation set
self.property_set["commutation_set"] = analyze_commutations(dag, self.comm_checker)
self.property_set["commutation_set"] = analyze_commutations(dag, self.comm_checker.cc)

0 comments on commit 68f4f4b

Please sign in to comment.