-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Context:** `QNode.interface` returns a `str` type, ```python @Property def interface(self) -> str: """The interface used by the QNode""" return self._interface.value ``` Therefore, this equality will never be true, ```python from pennylane.math.interface_utils import Interface >>> "jax" == Interface.JAX False ``` Moreover, `str` cannot be compared with `Enum` objects at all. 🤯 **Description of the Change:** - Adjust the `InterfaceEnum` class to have dunder methods to overwrite comparisons. This way it will error out if you try to compare it with a string. - Add test coverage for the private helpers in `qnode.py` Now we have, ```python from pennylane.math.interface_utils import Interface >>> "jax" == Interface.JAX TypeError: Cannot compare Interface with str ``` **Benefits:** Logic is correct. **Possible Drawbacks:** None identified. [sc-83034] --------- Co-authored-by: Yushao Chen (Jerry) <[email protected]>
- Loading branch information
1 parent
666941f
commit 721acb2
Showing
6 changed files
with
82 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters