From 040e9af2726710bb0ed08a5bc6439e60176ad382 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 07:01:45 +0000 Subject: [PATCH] Fix power() in subclass test for QuantumCircuit change (backport #172) (#174) Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com> --- qiskit_algorithms/gradients/reverse/derive_circuit.py | 4 ++-- test/test_amplitude_estimators.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qiskit_algorithms/gradients/reverse/derive_circuit.py b/qiskit_algorithms/gradients/reverse/derive_circuit.py index 57774fc3..e4978877 100644 --- a/qiskit_algorithms/gradients/reverse/derive_circuit.py +++ b/qiskit_algorithms/gradients/reverse/derive_circuit.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2022, 2023. +# (C) Copyright IBM 2022, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -148,7 +148,7 @@ def derive_circuit( gradient = [] for product_rule_term in itertools.product(*summands): summand_circuit = QuantumCircuit(*circuit.qregs) - c = 1 + c = complex(1) for i, term in enumerate(product_rule_term): c *= term[0] summand_circuit.data.append([term[1], *op_context[i]]) diff --git a/test/test_amplitude_estimators.py b/test/test_amplitude_estimators.py index 4aa3e281..0969ddb9 100644 --- a/test/test_amplitude_estimators.py +++ b/test/test_amplitude_estimators.py @@ -1,6 +1,6 @@ # This code is part of a Qiskit project. # -# (C) Copyright IBM 2018, 2023. +# (C) Copyright IBM 2018, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -47,7 +47,9 @@ def __init__(self, probability): self.angle = 2 * np.arcsin(np.sqrt(probability)) self.ry(2 * self.angle, 0) - def power(self, power, matrix_power=False): + # Disable for pylint needed for Qiskit < 1.1.0 where annotated does not exist + # pylint: disable=unused-argument + def power(self, power, matrix_power=False, annotated: bool = False): if matrix_power: return super().power(power, True)