Skip to content

Commit f4c5156

Browse files
Update Statevector and DensityMatrix evolve to work with operator qargs attr (Qiskit#3983)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 4342f75 commit f4c5156

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

qiskit/quantum_info/states/densitymatrix.py

+3
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def evolve(self, other, qargs=None):
216216
QiskitError: if the operator dimension does not match the
217217
specified QuantumState subsystem dimensions.
218218
"""
219+
if qargs is None:
220+
qargs = getattr(other, 'qargs', None)
221+
219222
# Evolution by a circuit or instruction
220223
if isinstance(other, (QuantumCircuit, Instruction)):
221224
return self._evolve_instruction(other, qargs=qargs)

qiskit/quantum_info/states/statevector.py

+3
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ def evolve(self, other, qargs=None):
197197
QiskitError: if the operator dimension does not match the
198198
specified Statevector subsystem dimensions.
199199
"""
200+
if qargs is None:
201+
qargs = getattr(other, 'qargs', None)
202+
200203
# Evolution by a circuit or instruction
201204
if isinstance(other, (QuantumCircuit, Instruction)):
202205
return self._evolve_instruction(other, qargs=qargs)

0 commit comments

Comments
 (0)