qp.core.operator.Operator1¶
- class Operator1(*args, **kwargs)[source]¶
Bases:
ABCA class for checking if a object specifying implements the old version of
Operator.While inheriting from
Operatorprovides the old, version 1 interface, usingOperatorwithisinstanceandissubclasschecks returns whether an object is eitherOperatoror the newOperator2. This has been done to speed up integration, as the exposed interfaces are mostly the same. ThisOperator1class can be used to check if an instance is specifically the old version of the interface.Suppose we have an old operator and a new operator:
class OldOp(qp.core.Operator): pass class NewOp(qp.core.Operator2): def __init__(self, wires): super().__init__(wires) old_op = OldOp(wires=0) new_op = NewOp(wires=0)
We can see that both versions are “instances” of
Operator:>>> isinstance(old_op, qp.core.Operator) True >>> isinstance(new_op, qp.core.Operator) True
but only
old_opis an instance ofOperator1.>>> isinstance(old_op, qp.core.Operator1) True >>> isinstance(new_op, qp.core.Operator1) False
When inheriting from this class, it is switched out for
Operator. The following is equivalent to inheriting fromqp.core.Operator.class AnotherOldOp(qp.core.Operator1): pass