Skip to content

Commit

Permalink
Flat tensor wires (#53)
Browse files Browse the repository at this point in the history
* Changing to processing flat wire sequences

* Require master version of PL

* Docstring

* Rephrase test name

* Pinning pennylane>=0.10

* Increase tol

* Update tests/test_qpu.py

Co-authored-by: Josh Izaac <josh146@gmail.com>
  • Loading branch information
antalszava and josh146 committed Jun 23, 2020
1 parent 3ae4aff commit f692b4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions pennylane_forest/qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def expval(self, observable):
# the product of PauliZ operators on those qubits
pauli_obs = sI()
for wire in observable.wires:
qubit = wire[0]
qubit = wire
pauli_obs *= sZ(self.wiring[qubit])


Expand All @@ -202,10 +202,7 @@ def expval(self, observable):

if self.readout_error is not None:
for wire in observable.wires:
if isinstance(wire, int):
qubit = wire
elif isinstance(wire, List):
qubit = wire[0]
qubit = wire
prep_prog.define_noisy_readout(
self.wiring[qubit], p00=self.readout_error[0], p11=self.readout_error[1]
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyquil>=2.16
pennylane>=0.9
pennylane>=0.10
networkx
flaky
6 changes: 3 additions & 3 deletions tests/test_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_qpu_args(self):
@pytest.mark.parametrize(
"obs", [qml.PauliX(0), qml.PauliZ(0), qml.PauliY(0), qml.Hadamard(0), qml.Identity(0)]
)
def test_tensor_wires_expval_parametric_compilation(self, obs):
def test_tensor_expval_parametric_compilation(self, obs):
"""Test the QPU expval method for Tensor observables made up of a single observable when parametric compilation is
turned on.
Expand Down Expand Up @@ -107,7 +107,7 @@ def circuit_obs(param):
@pytest.mark.parametrize(
"obs", [qml.PauliX(0), qml.PauliZ(0), qml.PauliY(0), qml.Hadamard(0), qml.Identity(0)]
)
def test_tensor_wires_expval_operator_estimation(self, obs):
def test_tensor_expval_operator_estimation(self, obs):
"""Test the QPU expval method for Tensor observables made up of a single observable when parametric compilation is
turned off allowing operator estimation.
Expand Down Expand Up @@ -366,7 +366,7 @@ def circuit():

result = circuit()

assert np.isclose(result, 0.5, atol=2e-2)
assert np.isclose(result, 0.5, atol=3e-2)

@flaky(max_runs=5, min_passes=3)
def test_2q_gate(self):
Expand Down

0 comments on commit f692b4b

Please sign in to comment.