qml.operation.enable_new_opmath¶
- enable_new_opmath(warn=True)[source]¶
Change dunder methods to return arithmetic operators instead of Hamiltonians and Tensors
Warning
Using legacy operator arithmetic is deprecated, and will be removed in PennyLane v0.40. For further details, see Updated Operators.
- Parameters
warn (bool) – Whether or not to emit a warning for re-enabling new opmath. Default is
True
.
Example
>>> qml.operation.active_new_opmath() False >>> type(qml.X(0) @ qml.Z(1)) <class 'pennylane.operation.Tensor'> >>> qml.operation.enable_new_opmath() >>> type(qml.X(0) @ qml.Z(1)) <class 'pennylane.ops.op_math.prod.Prod'>
code/api/pennylane.operation.enable_new_opmath
Download Python script
Download Notebook
View on GitHub