From 8080d1add8ae48502015f7f529d36b908c70b32d Mon Sep 17 00:00:00 2001 From: Eugenio Gigante Date: Fri, 31 May 2024 16:06:42 +0200 Subject: [PATCH] [#5644] improve operator support for new assert_equal function: group 1 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. --- doc/releases/changelog-dev.md | 1 + pennylane/ops/functions/equal.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 584d9d7c393..fe20734a31f 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -276,6 +276,7 @@ Ahmed Darwish, Isaac De Vlugt, Diksha Dhawan, Pietropaolo Frisoni, +Eugenio Gigante, Emiliano Godinez, David Ittah, Soran Jahangiri, diff --git a/pennylane/ops/functions/equal.py b/pennylane/ops/functions/equal.py index 87d09f8c92b..f2525f85512 100644 --- a/pennylane/ops/functions/equal.py +++ b/pennylane/ops/functions/equal.py @@ -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}."