Skip to content

Commit

Permalink
Small fixes for compatibility with most recent Qiskit version (#347)
Browse files Browse the repository at this point in the history
* don't convert everything into QubitUnitary

* remove irrelevant test

* typo

* still use op.__class__ for versions with no op.base_class

* Update pennylane_qiskit/converter.py

Co-authored-by: Matthew Silverman <[email protected]>

* Update pennylane_qiskit/converter.py

Co-authored-by: Tom Bromley <[email protected]>

---------

Co-authored-by: Matthew Silverman <[email protected]>
Co-authored-by: Tom Bromley <[email protected]>
  • Loading branch information
3 people authored Nov 9, 2023
1 parent 723074e commit 1dd2366
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
3 changes: 2 additions & 1 deletion pennylane_qiskit/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def _function(params: dict = None, wires: list = None):

# Processing the dictionary of parameters passed
for op, qargs, cargs in qc.data:
instruction_name = op.__class__.__name__
# the new Singleton classes have different names than the objects they represent, but base_class.__name__ still matches
instruction_name = getattr(op, "base_class", op.__class__).__name__

operation_wires = [wire_map[hash(qubit)] for qubit in qargs]

Expand Down
15 changes: 0 additions & 15 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,6 @@ def test_extra_parameters_were_passed(self, recorder):
with recorder:
quantum_circuit(params={theta: x, phi: y})

def test_quantum_circuit_error_by_passing_wrong_parameters(self, recorder):
"""Tests the load method for a QuantumCircuit raises a QiskitError,
if the wrong type of arguments were passed."""

theta = Parameter("θ")
angle = np.tensor("some_string_instead_of_an_angle", requires_grad=False)

qc = QuantumCircuit(3, 1)
qc.rz(theta, [0])

quantum_circuit = load(qc)

with pytest.raises(QiskitError):
with recorder:
quantum_circuit(params={theta: angle})

def test_quantum_circuit_error_passing_parameters_not_required(self, recorder):
"""Tests the load method raises a QiskitError if arguments
Expand Down

0 comments on commit 1dd2366

Please sign in to comment.