You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Comparing two instructions that have matrix parameters fails ungracefully with ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Matrix parameters for instructions are currently generated when converting Aer's errors to instructions.
Steps to reproduce the problem
The following code raises this error:
from qiskit import QuantumRegister, QuantumCircuit
from qiskit.providers.aer.noise.errors.standard_errors import pauli_error
qr = QuantumRegister(1, 'qr')
circuit = QuantumCircuit(qr)
error = pauli_error([('X', 0.25), ('I', 0.75)])
circuit.append(error.to_instruction(), [qr[0]])
circuit == circuit
What is the expected behavior?
Correct element-by-element comparison of the matrices, using numpy.isclose for almost-identical matrices.
Suggested solutions
Line 99 in instruction.py needs to be modified; it seems type-checking the parameter is needed (maybe isinstance(self_param, numpy.ndarray?). For Numpy arrays numpy.equalandnumpy.iscloseworks and returns a boolean array of results, on whichall()` can be used.
The text was updated successfully, but these errors were encountered:
Information
What is the current behavior?
Comparing two instructions that have matrix parameters fails ungracefully with
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Matrix parameters for instructions are currently generated when converting Aer's errors to instructions.
Steps to reproduce the problem
The following code raises this error:
What is the expected behavior?
Correct element-by-element comparison of the matrices, using
numpy.isclose
for almost-identical matrices.Suggested solutions
Line 99 in instruction.py needs to be modified; it seems type-checking the parameter is needed (maybe
isinstance(self_param, numpy.ndarray?). For Numpy arrays
numpy.equaland
numpy.iscloseworks and returns a boolean array of results, on which
all()` can be used.The text was updated successfully, but these errors were encountered: