Skip to content

Commit

Permalink
Map wires
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoyard committed Oct 17, 2023
1 parent e6eb319 commit 77cda0d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions pennylane/ops/functions/map_wires.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ def _map_wires_transform(

out = tape.__class__(ops=ops, measurements=measurements, shots=tape.shots)
out.trainable_params = tape.trainable_params
print("inc", out.circuit)
print(wire_map)

def processing_fn(res):
"""Defines how matrix works if applied to a tape containing multiple operations."""
Expand Down
3 changes: 2 additions & 1 deletion pennylane/tape/qscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,8 @@ def map_to_standard_wires(self):
return self

wire_map = {w: i for i, w in enumerate(op_wires + meas_only_wires)}
return qml.map_wires(self, wire_map)
tapes, fn = qml.map_wires(self, wire_map)
return fn(tapes)


def make_qscript(fn, shots: Optional[Union[int, Sequence, Shots]] = None):
Expand Down
11 changes: 7 additions & 4 deletions tests/ops/functions/test_map_wires.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,13 @@ def qnode():
m_qnode = qml.map_wires(qnode, wire_map=wire_map)
assert m_qnode() == qnode()
assert len(m_qnode.tape) == 2
m_op = m_qnode.tape.operations[0]
m_obs = m_qnode.tape.observables[0]
assert qml.equal(m_op, mapped_op)
assert qml.equal(m_obs, mapped_obs)
tapes, _ = m_qnode.transform_program((m_qnode.tape,))

m_op = tapes[0].operations
m_obs = tapes[0].observables

assert qml.equal(m_op[0], mapped_op)
assert qml.equal(m_obs[0], mapped_obs)


class TestMapWiresCallables:
Expand Down

0 comments on commit 77cda0d

Please sign in to comment.