qns.entity.node package

Submodules

qns.entity.node.app module

class qns.entity.node.app.Application[source]

Bases: object

Application can be deployed on the quantum nodes.

add_handler(handler, EventTypeList: List = [], ByList: List = [])[source]

Add a handler function to the dispather.

Parameters:
  • handler – The handler to process the event. It is an object method whose function signature is the same to handle function.

  • EventTypeList – a list of Event Class Type. An empty list meaning to match all events.

  • ByList – a list of Entities, QNodes or Applications, that generates this event. An empty list meaning to match all entities.

get_node()[source]

get the node that runs this application

Returns:

the quantum node

get_simulator()[source]

get the simulator

Returns:

the simulator

handle(node, event: Event) bool | None[source]

process the event on the node.

Parameters:
  • node (QNode) – the node that will handle this event

  • event (Event) – the event

Returns:

if skip is True, further applications will not handle this event

Return type:

skip (bool, None)

install(node, simulator: Simulator)[source]

install initial events for this QNode

Parameters:
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

qns.entity.node.node module

class qns.entity.node.node.QNode(name: str | None = None, apps: List[Application] | None = None)[source]

Bases: Entity

QNode is a quantum node in the quantum network

add_apps(app: Application)[source]

Insert an Application into the app list.

Parameters:

app (Application) – the inserting application.

add_cchannel(cchannel)[source]

Add a classic channel in this QNode

Parameters:

cchannel (ClassicChannel) – the classic channel

add_memory(memory)[source]

Add a quantum memory in this QNode

Parameters:

memory (Memory) – the quantum memory

add_network(network)[source]

add a network object to this node

Parameters:

network (qns.network.network.Network) – the network object

add_operator(operator)[source]

Add a quantum operator in this node

Parameters:

operator (QuantumOperator) – the quantum operator

add_qchannel(qchannel)[source]

Add a quantum channel in this QNode

Parameters:

qchannel (QuantumChannel) – the quantum channel

add_request(request)[source]

add a request to this node

Parameters:

request (Request) – the inserting request

clear_request()[source]

clear all requests

get_apps(app_type)[source]

Get an Application that is app_type

Parameters:

app_type – the class of app_type

get_cchannel(dst: QNode)[source]

Get the classic channel that connects to the dst

Parameters:

dst (QNode) – the destination

get_memory(memory: str | int)[source]

Get the memory by index (in memories) or its name

Parameters:

memory (Union[str, int]) – the index or name of the memory

get_qchannel(dst: QNode)[source]

Get the quantum channel that connects to the dst

Parameters:

dst (QNode) – the destination

handle(event: Event) None[source]

This function will handle an Event. This event will be passed to every applications in apps list in order.

Parameters:

event (Event) – the event that happens on this QNode

install(simulator: Simulator) None[source]

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

Parameters:

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

Module contents

class qns.entity.node.Application[source]

Bases: object

Application can be deployed on the quantum nodes.

add_handler(handler, EventTypeList: List = [], ByList: List = [])[source]

Add a handler function to the dispather.

Parameters:
  • handler – The handler to process the event. It is an object method whose function signature is the same to handle function.

  • EventTypeList – a list of Event Class Type. An empty list meaning to match all events.

  • ByList – a list of Entities, QNodes or Applications, that generates this event. An empty list meaning to match all entities.

get_node()[source]

get the node that runs this application

Returns:

the quantum node

get_simulator()[source]

get the simulator

Returns:

the simulator

handle(node, event: Event) bool | None[source]

process the event on the node.

Parameters:
  • node (QNode) – the node that will handle this event

  • event (Event) – the event

Returns:

if skip is True, further applications will not handle this event

Return type:

skip (bool, None)

install(node, simulator: Simulator)[source]

install initial events for this QNode

Parameters:
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

class qns.entity.node.QNode(name: str | None = None, apps: List[Application] | None = None)[source]

Bases: Entity

QNode is a quantum node in the quantum network

add_apps(app: Application)[source]

Insert an Application into the app list.

Parameters:

app (Application) – the inserting application.

add_cchannel(cchannel)[source]

Add a classic channel in this QNode

Parameters:

cchannel (ClassicChannel) – the classic channel

add_memory(memory)[source]

Add a quantum memory in this QNode

Parameters:

memory (Memory) – the quantum memory

add_network(network)[source]

add a network object to this node

Parameters:

network (qns.network.network.Network) – the network object

add_operator(operator)[source]

Add a quantum operator in this node

Parameters:

operator (QuantumOperator) – the quantum operator

add_qchannel(qchannel)[source]

Add a quantum channel in this QNode

Parameters:

qchannel (QuantumChannel) – the quantum channel

add_request(request)[source]

add a request to this node

Parameters:

request (Request) – the inserting request

clear_request()[source]

clear all requests

get_apps(app_type)[source]

Get an Application that is app_type

Parameters:

app_type – the class of app_type

get_cchannel(dst: QNode)[source]

Get the classic channel that connects to the dst

Parameters:

dst (QNode) – the destination

get_memory(memory: str | int)[source]

Get the memory by index (in memories) or its name

Parameters:

memory (Union[str, int]) – the index or name of the memory

get_qchannel(dst: QNode)[source]

Get the quantum channel that connects to the dst

Parameters:

dst (QNode) – the destination

handle(event: Event) None[source]

This function will handle an Event. This event will be passed to every applications in apps list in order.

Parameters:

event (Event) – the event that happens on this QNode

install(simulator: Simulator) None[source]

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

Parameters:

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