qp.core.operator.Operator1

class Operator1(*args, **kwargs)[source]

Bases: ABC

A class for checking if a object specifying implements the old version of Operator.

While inheriting from Operator provides the old, version 1 interface, using Operator with isinstance and issubclass checks returns whether an object is either Operator or the new Operator2. This has been done to speed up integration, as the exposed interfaces are mostly the same. This Operator1 class 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_op is an instance of Operator1.

>>> 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 from qp.core.Operator.

class AnotherOldOp(qp.core.Operator1):
    pass