qns.entity.operator package

Submodules

qns.entity.operator.event module

class qns.entity.operator.event.OperateRequestEvent(operator, qubits: List[qns.models.core.backend.QuantumModel] = [], t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

OperateRequestEvent is the event that request a operator to handle

invoke() None[source]

Invoke the event, should be implemented

class qns.entity.operator.event.OperateResponseEvent(node: qns.entity.node.node.QNode, result: Optional[Union[int, List[int]]] = None, request: Optional[qns.entity.operator.event.OperateRequestEvent] = None, t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

OperateResponseEvent is the event that returns the operating result

invoke() None[source]

Invoke the event, should be implemented

qns.entity.operator.operator module

class qns.entity.operator.operator.QuantumOperator(name: Optional[str] = None, node: Optional[qns.entity.node.node.QNode] = None, gate: Optional[Callable[[...], Union[None, int, List[int]]]] = None, delay: Union[float, qns.models.delay.delay.DelayModel] = 0)[source]

Bases: qns.entity.entity.Entity

Quantum operator can perfrom quantum operation or measurements on qubits. It has two modes:

Synchronous mode, users can use the operate function to operate qubits directly without delay Asynchronous mode, users will use events to operate quantum operations asynchronously

handle(event: qns.simulator.event.Event) None[source]

handle is called to process an receiving Event.

Parameters

event (qns.simulator.event.Event) – the event that send to this entity

install(simulator: qns.simulator.simulator.Simulator) None[source]

install is called before simulator runs to initialize or set initial events

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

operate(*qubits) Optional[Union[int, List[int]]][source]

operate on qubits and return the measure result

Parameters

qubits – the operating qubits

Returns

the measure result

set_own(node: qns.entity.node.node.QNode)[source]

set the owner of this quantum operator

qns.entity.operator.operator module

class qns.entity.operator.operator.QuantumOperator(name: Optional[str] = None, node: Optional[qns.entity.node.node.QNode] = None, gate: Optional[Callable[[...], Union[None, int, List[int]]]] = None, delay: Union[float, qns.models.delay.delay.DelayModel] = 0)[source]

Bases: qns.entity.entity.Entity

Quantum operator can perfrom quantum operation or measurements on qubits. It has two modes:

Synchronous mode, users can use the operate function to operate qubits directly without delay Asynchronous mode, users will use events to operate quantum operations asynchronously

handle(event: qns.simulator.event.Event) None[source]

handle is called to process an receiving Event.

Parameters

event (qns.simulator.event.Event) – the event that send to this entity

install(simulator: qns.simulator.simulator.Simulator) None[source]

install is called before simulator runs to initialize or set initial events

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

operate(*qubits) Optional[Union[int, List[int]]][source]

operate on qubits and return the measure result

Parameters

qubits – the operating qubits

Returns

the measure result

set_own(node: qns.entity.node.node.QNode)[source]

set the owner of this quantum operator

Module contents

class qns.entity.operator.OperateRequestEvent(operator, qubits: List[qns.models.core.backend.QuantumModel] = [], t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

OperateRequestEvent is the event that request a operator to handle

invoke() None[source]

Invoke the event, should be implemented

class qns.entity.operator.OperateResponseEvent(node: qns.entity.node.node.QNode, result: Optional[Union[int, List[int]]] = None, request: Optional[qns.entity.operator.event.OperateRequestEvent] = None, t: Optional[qns.simulator.ts.Time] = None, name: Optional[str] = None, by: Optional[Any] = None)[source]

Bases: qns.simulator.event.Event

OperateResponseEvent is the event that returns the operating result

invoke() None[source]

Invoke the event, should be implemented

class qns.entity.operator.QuantumOperator(name: Optional[str] = None, node: Optional[qns.entity.node.node.QNode] = None, gate: Optional[Callable[[...], Union[None, int, List[int]]]] = None, delay: Union[float, qns.models.delay.delay.DelayModel] = 0)[source]

Bases: qns.entity.entity.Entity

Quantum operator can perfrom quantum operation or measurements on qubits. It has two modes:

Synchronous mode, users can use the operate function to operate qubits directly without delay Asynchronous mode, users will use events to operate quantum operations asynchronously

handle(event: qns.simulator.event.Event) None[source]

handle is called to process an receiving Event.

Parameters

event (qns.simulator.event.Event) – the event that send to this entity

install(simulator: qns.simulator.simulator.Simulator) None[source]

install is called before simulator runs to initialize or set initial events

Parameters

simulator (qns.simulator.simulator.Simulator) – the simulator

operate(*qubits) Optional[Union[int, List[int]]][source]

operate on qubits and return the measure result

Parameters

qubits – the operating qubits

Returns

the measure result

set_own(node: qns.entity.node.node.QNode)[source]

set the owner of this quantum operator