Skip to content

Commit 2d5dd90

Browse files
authored
Upgrade to cirq 0.12 (#748)
1 parent de77eec commit 2d5dd90

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
cirq~=0.11.0
1+
cirq-core~=0.12.0
2+
cirq-google~=0.12.0
23
deprecation
34
h5py>=2.8
45
networkx
@@ -7,4 +8,4 @@ pubchempy
78
requests~=2.18
89
scipy>=1.1.0
910
sympy
10-
nbformat
11+
nbformat

src/openfermion/_compat_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ def test_cirq_deprecations():
7575
def old_func():
7676
pass
7777

78-
with pytest.raises(ValueError, match="should not use deprecated"):
78+
with pytest.raises(ValueError, match="deprecated .* not allowed"):
7979
old_func()

src/openfermion/circuits/gates/common_gates.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import cirq
1919

2020

21-
class FSwapPowGate(cirq.EigenGate, cirq.InterchangeableQubitsGate,
22-
cirq.TwoQubitGate):
21+
class FSwapPowGate(cirq.EigenGate, cirq.InterchangeableQubitsGate):
2322
"""The FSWAP gate, possibly raised to a power.
2423
2524
FSwapPowGate()**t = FSwapPowGate(exponent=t) and acts on two qubits in the

src/openfermion/circuits/gates/fermionic_simulation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def interaction_operator_generator(
398398

399399
class QuadraticFermionicSimulationGate(InteractionOperatorFermionicGate,
400400
cirq.InterchangeableQubitsGate,
401-
cirq.TwoQubitGate, cirq.EigenGate):
401+
cirq.EigenGate):
402402
r"""``(w0 |10⟩⟨01| + h.c.) + w1 |11⟩⟨11|`` interaction.
403403
404404
With weights $(w_0, w_1)$ and exponent $t$, this gate's matrix
@@ -435,6 +435,9 @@ class QuadraticFermionicSimulationGate(InteractionOperatorFermionicGate,
435435
def num_weights(cls):
436436
return 2
437437

438+
def _num_qubits_(self) -> int:
439+
return 2
440+
438441
def _decompose_(self, qubits):
439442
r = 2 * abs(self.weights[0]) / np.pi
440443
theta = _arg(self.weights[0]) / np.pi
@@ -532,7 +535,7 @@ def fswap(self, i: int = 0):
532535

533536

534537
class CubicFermionicSimulationGate(InteractionOperatorFermionicGate,
535-
cirq.ThreeQubitGate, cirq.EigenGate):
538+
cirq.EigenGate):
536539
r"""``w0|110⟩⟨101| + w1|110⟩⟨011| + w2|101⟩⟨011|`` + h.c. interaction.
537540
538541
With weights $(w_0, w_1, w_2)$ and exponent $t$, this gate's
@@ -576,6 +579,9 @@ class CubicFermionicSimulationGate(InteractionOperatorFermionicGate,
576579
def num_weights(cls):
577580
return 3
578581

582+
def _num_qubits_(self) -> int:
583+
return 3
584+
579585
@classmethod
580586
def wire_symbol(cls, use_unicode: bool):
581587
return '↕↓↑' if use_unicode else 'na*a'

0 commit comments

Comments
 (0)