From 542ffc58c0de438ac420d9e502685a89b315c399 Mon Sep 17 00:00:00 2001 From: Anurudh Peduri <7265746+anurudhp@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:00:10 -0700 Subject: [PATCH] fix call graph for `Equals` (#1429) --- qualtran/bloqs/arithmetic/comparison.py | 7 +------ qualtran/bloqs/arithmetic/comparison_test.py | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qualtran/bloqs/arithmetic/comparison.py b/qualtran/bloqs/arithmetic/comparison.py index 3c7cc76b2..272ea8abe 100644 --- a/qualtran/bloqs/arithmetic/comparison.py +++ b/qualtran/bloqs/arithmetic/comparison.py @@ -1008,12 +1008,7 @@ def build_call_graph(self, ssa: 'SympySymbolAllocator') -> 'BloqCountDictT': cvs = [0] * self.bitsize else: cvs = HasLength(self.bitsize) - return { - Xor(self.dtype): 2, - MultiControlX(cvs=cvs): 1, - MultiAnd(cvs=cvs).adjoint(): 1, - CNOT(): 1, - } + return {Xor(self.dtype): 2, MultiControlX(cvs=cvs): 1} def on_classical_vals(self, x: int, y: int, target: int) -> Dict[str, 'ClassicalValT']: return {'x': x, 'y': y, 'target': target ^ (x == y)} diff --git a/qualtran/bloqs/arithmetic/comparison_test.py b/qualtran/bloqs/arithmetic/comparison_test.py index 50ea8678c..f755d1eb7 100644 --- a/qualtran/bloqs/arithmetic/comparison_test.py +++ b/qualtran/bloqs/arithmetic/comparison_test.py @@ -310,6 +310,12 @@ def test_classical_equals(dtype): ) +def test_equals_call_graph(): + bloq = Equals(QUInt(4)) + + qlt_testing.assert_equivalent_bloq_counts(bloq, ignore_split_join) + + def test_equals_a_constant(): bb = BloqBuilder() bitsize = 5