diff --git a/squidasm/run/stack/config.py b/squidasm/run/stack/config.py index 739c765..334f948 100644 --- a/squidasm/run/stack/config.py +++ b/squidasm/run/stack/config.py @@ -4,9 +4,9 @@ from typing import Any, List, Optional import netsquid_netbuilder.base_configs as netbuilder_configs -import netsquid_netbuilder.modules.qdevices as netbuilder_qdevices -import netsquid_netbuilder.modules.links as netbuilder_links import netsquid_netbuilder.modules.clinks as netbuilder_clinks +import netsquid_netbuilder.modules.links as netbuilder_links +import netsquid_netbuilder.modules.qdevices as netbuilder_qdevices from netsquid_netbuilder.yaml_loadable import YamlLoadable @@ -107,6 +107,7 @@ class StackNetworkConfig(YamlLoadable): """List of all the links connecting the stacks in the network.""" clinks: Optional[List[LinkConfig]] """List of all the links connecting the stacks in the network.""" + @classmethod def from_file(cls, path: str) -> StackNetworkConfig: return super().from_file(path) # type: ignore @@ -122,7 +123,7 @@ def _convert_stack_network_config( processing_node = netbuilder_configs.ProcessingNodeConfig( name=stack_config.name, qdevice_typ=stack_config.qdevice_typ, - qdevice_cfg=stack_config.qdevice_cfg + qdevice_cfg=stack_config.qdevice_cfg, ) processing_nodes.append(processing_node) @@ -167,6 +168,5 @@ def _convert_stack_network_config( clinks.append(clink) return netbuilder_configs.NetworkConfig( - processing_nodes=processing_nodes, - links=links, - clinks=clinks) + processing_nodes=processing_nodes, links=links, clinks=clinks + ) diff --git a/squidasm/run/stack/run.py b/squidasm/run/stack/run.py index 0807fdb..1694d88 100644 --- a/squidasm/run/stack/run.py +++ b/squidasm/run/stack/run.py @@ -9,13 +9,12 @@ from netsquid_netbuilder.base_configs import NetworkConfig from squidasm.run.stack.build import create_stack_network_builder +from squidasm.run.stack.config import StackNetworkConfig, _convert_stack_network_config from squidasm.sim.stack.context import NetSquidContext from squidasm.sim.stack.globals import GlobalSimData from squidasm.sim.stack.program import Program from squidasm.sim.stack.qnos_network_service import QNOSNetworkService from squidasm.sim.stack.stack import NodeStack, StackNetwork, StackNode -from squidasm.run.stack.config import StackNetworkConfig -from squidasm.run.stack.config import _convert_stack_network_config def _setup_network(config: NetworkConfig) -> StackNetwork: @@ -79,7 +78,9 @@ def _run(network: StackNetwork) -> List[List[Dict[str, Any]]]: def run( - config: Union[NetworkConfig, StackNetworkConfig], programs: Dict[str, Program], num_times: int = 1 + config: Union[NetworkConfig, StackNetworkConfig], + programs: Dict[str, Program], + num_times: int = 1, ) -> List[List[Dict[str, Any]]]: """Run programs on a network specified by a network configuration. diff --git a/squidasm/sim/stack/csocket.py b/squidasm/sim/stack/csocket.py index d8ab835..284d0ca 100644 --- a/squidasm/sim/stack/csocket.py +++ b/squidasm/sim/stack/csocket.py @@ -2,4 +2,4 @@ class ClassicalSocket(netsquid_classical_socket.ClassicalSocket): - pass \ No newline at end of file + pass diff --git a/squidasm/util/__init__.py b/squidasm/util/__init__.py index f7655f5..86048c9 100644 --- a/squidasm/util/__init__.py +++ b/squidasm/util/__init__.py @@ -1 +1 @@ -from .util import get_qubit_state, get_reference_state, create_two_node_network +from .util import create_two_node_network, get_qubit_state, get_reference_state diff --git a/squidasm/util/util.py b/squidasm/util/util.py index 9d3b34b..2624a9a 100644 --- a/squidasm/util/util.py +++ b/squidasm/util/util.py @@ -7,9 +7,16 @@ from netsquid.qubits import operators from netsquid.qubits import qubitapi as qapi - import squidasm.sim.stack.globals -from squidasm.run.stack.config import StackNetworkConfig, CLinkConfig, LinkConfig, StackConfig, DepolariseLinkConfig, GenericQDeviceConfig, DefaultCLinkConfig +from squidasm.run.stack.config import ( + CLinkConfig, + DefaultCLinkConfig, + DepolariseLinkConfig, + GenericQDeviceConfig, + LinkConfig, + StackConfig, + StackNetworkConfig, +) def create_two_node_network( @@ -51,9 +58,7 @@ def create_two_node_network( typ="default", cfg=DefaultCLinkConfig(delay=clink_delay), ) - return StackNetworkConfig( - stacks=processing_nodes, links=[link], clinks=[clink] - ) + return StackNetworkConfig(stacks=processing_nodes, links=[link], clinks=[clink]) def get_qubit_state(q: Qubit, node_name, full_state=False) -> np.ndarray: