Skip to content

Commit

Permalink
[#5644] improve operator support for new assert_equal function: group 1
Browse files Browse the repository at this point in the history
As suggested in [#5644], makes kernels _equals_operators, _equal_controlled
_equal_pow, _equal_adjoint and _equal_exp return either True or a string
explaining why two operators are not the same.
  • Loading branch information
EuGig committed Jun 3, 2024
1 parent 7b4d6de commit 8080d1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ Ahmed Darwish,
Isaac De Vlugt,
Diksha Dhawan,
Pietropaolo Frisoni,
Eugenio Gigante,
Emiliano Godinez,
David Ittah,
Soran Jahangiri,
Expand Down
2 changes: 1 addition & 1 deletion pennylane/ops/functions/equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def _equal_controlled(op1: Controlled, op2: Controlled, **kwargs):
if dict(zip(op1.control_wires, op1.control_values)) != dict(
zip(op2.control_wires, op2.control_values)
):
return f"op1 and op2 have different control wires/values. "
return "op1 and op2 have different control wires/values."

if not qml.equal(op1.base, op2.base, **kwargs):
return f"op1 and op2 have different bases because op1.base is not equal to op2.base. Got {op1.base} and {op2.base}."
Expand Down

0 comments on commit 8080d1a

Please sign in to comment.