From c573d1ed046d1a0bd9475f03fca2bd6c1cc142f1 Mon Sep 17 00:00:00 2001 From: Tanuj Khattar Date: Tue, 19 Oct 2021 15:57:26 -0700 Subject: [PATCH] Upgrade to cirq 0.12 --- requirements.txt | 5 +++-- src/openfermion/_compat_test.py | 2 +- src/openfermion/circuits/gates/common_gates.py | 3 +-- src/openfermion/circuits/gates/fermionic_simulation.py | 10 ++++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 21fe7e800..9bf634983 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -cirq~=0.11.0 +cirq-core~=0.12.0 +cirq-google~=0.12.0 deprecation h5py>=2.8 networkx @@ -7,4 +8,4 @@ pubchempy requests~=2.18 scipy>=1.1.0 sympy -nbformat \ No newline at end of file +nbformat diff --git a/src/openfermion/_compat_test.py b/src/openfermion/_compat_test.py index 9775dcc55..e9637b644 100644 --- a/src/openfermion/_compat_test.py +++ b/src/openfermion/_compat_test.py @@ -75,5 +75,5 @@ def test_cirq_deprecations(): def old_func(): pass - with pytest.raises(ValueError, match="should not use deprecated"): + with pytest.raises(ValueError, match="deprecated .* not allowed"): old_func() diff --git a/src/openfermion/circuits/gates/common_gates.py b/src/openfermion/circuits/gates/common_gates.py index bc2f9c657..695432bd8 100644 --- a/src/openfermion/circuits/gates/common_gates.py +++ b/src/openfermion/circuits/gates/common_gates.py @@ -18,8 +18,7 @@ import cirq -class FSwapPowGate(cirq.EigenGate, cirq.InterchangeableQubitsGate, - cirq.TwoQubitGate): +class FSwapPowGate(cirq.EigenGate, cirq.InterchangeableQubitsGate): """The FSWAP gate, possibly raised to a power. FSwapPowGate()**t = FSwapPowGate(exponent=t) and acts on two qubits in the diff --git a/src/openfermion/circuits/gates/fermionic_simulation.py b/src/openfermion/circuits/gates/fermionic_simulation.py index b54594266..3c03e1193 100644 --- a/src/openfermion/circuits/gates/fermionic_simulation.py +++ b/src/openfermion/circuits/gates/fermionic_simulation.py @@ -398,7 +398,7 @@ def interaction_operator_generator( class QuadraticFermionicSimulationGate(InteractionOperatorFermionicGate, cirq.InterchangeableQubitsGate, - cirq.TwoQubitGate, cirq.EigenGate): + cirq.EigenGate): r"""``(w0 |10⟩⟨01| + h.c.) + w1 |11⟩⟨11|`` interaction. With weights $(w_0, w_1)$ and exponent $t$, this gate's matrix @@ -435,6 +435,9 @@ class QuadraticFermionicSimulationGate(InteractionOperatorFermionicGate, def num_weights(cls): return 2 + def _num_qubits_(self) -> int: + return 2 + def _decompose_(self, qubits): r = 2 * abs(self.weights[0]) / np.pi theta = _arg(self.weights[0]) / np.pi @@ -532,7 +535,7 @@ def fswap(self, i: int = 0): class CubicFermionicSimulationGate(InteractionOperatorFermionicGate, - cirq.ThreeQubitGate, cirq.EigenGate): + cirq.EigenGate): r"""``w0|110⟩⟨101| + w1|110⟩⟨011| + w2|101⟩⟨011|`` + h.c. interaction. With weights $(w_0, w_1, w_2)$ and exponent $t$, this gate's @@ -576,6 +579,9 @@ class CubicFermionicSimulationGate(InteractionOperatorFermionicGate, def num_weights(cls): return 3 + def _num_qubits_(self) -> int: + return 3 + @classmethod def wire_symbol(cls, use_unicode: bool): return '↕↓↑' if use_unicode else 'na*a'