-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapting generators to opmath enabled/disabled (#5415)
**Context:** After enabling the new operator arithmetic by default, we want the generators in the source code to return a `LinearCombination` instance or a `Hamiltonian` instance wherever possible. **Description of the Change:** The generators touched in this PR are modified so that they return `qml.Hamiltonian` instead of `Sum`, `Prod`, or `Sprod` instances. When opmath is enabled, `qml.Hamiltonian` points to `pennylane.ops.op_math.linear_combination.LinearCombination`, and when it is disabled, it points to `pennylane.ops.qubit.hamiltonian.Hamiltonian`. This ensures that the appropriate instance is used consistently. Note that the generators unchanged in this PR are modified (wherever possible) in #5410 , #5411 , #5412 (including the changelog entry). **Benefits:** A more coherent choice depending on whether opmath is enabled or disabled. **Possible Drawbacks:** None that I can think of, except that old opmath would be deprecated in the future. Therefore, some precautions that have been taken here (to ensure that tests associated with generators work even with opmath disabled) might become useless. **Related GitHub Issues:** None. [sc-57982] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: lillian542 <Lillian.frederiksen@xanadu.ai> Co-authored-by: qottmann <korbinian.kottmann@gmail.com> Co-authored-by: Alex Preciado <alex.preciado@xanadu.ai>
- Loading branch information
1 parent
6966f7f
commit c290f28
Showing
7 changed files
with
29 additions
and
26 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
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