def setUpClass(cls): Settings.default_settings() cls.network = Network(nodes=["Alice", "Bob"]) cls.network.start() cls.alice = CQCConnection("Alice") cls.bob = CQCConnection("Bob")
def setUpClass(cls): cls._alice = None cls._bob = None Settings.default_settings() cls.network = Network(nodes=["Alice", "Bob"]) cls.network.start()
def setUpClass(cls): cls.iterations = 100 sys.stdout.write( "Testing factory gates with {} iterations \r\n".format( cls.iterations)) Settings.default_settings() cls.network = Network() cls.network.start()
def tearDownClass(cls): # Set config files back to default for file in ["Nodes.cfg", "topology.json", "settings.ini"]: simulaqron_path = get_simulaqron_path.main() file_path = os.path.join(simulaqron_path, "config", file) os.remove(file_path) construct_node_configs() Settings.default_settings()
def setUpClass(cls): cls.iterations = 100 sys.stdout.write( "Testing single qubit gates gates with {} iterations \r\n".format( cls.iterations)) Settings.default_settings() cls.network = Network(nodes=["Alice"]) cls.network.start()
def max_registers(value): """How many registers a node can hold.""" Settings.set_setting("BACKEND", "maxregs_per_node", str(value))
def t1(value): """The effective T1 to be used for noisy qubits""" Settings.set_setting("BACKEND", "t1", str(value))
def noisy_qubits(value): """Whether qubits should be noisy (on/off)""" if value == "on": Settings.set_setting("BACKEND", "noisy_qubits", 'True') else: Settings.set_setting("BACKEND", "noisy_qubits", 'False')
def nodes_file(value): """The path to the topology file to be used, can be "".""" Settings.set_setting("BACKEND", "nodes_file", value)
def log_level(value): """Log level for both backend and frontend.""" Settings.set_setting("BACKEND", "loglevel", value) Settings.set_setting("FRONTEND", "loglevel", value)
def set_settings(settings): for section, section_settings in settings.items(): for key, value in section_settings.items(): Settings.set_setting(section=section, key=key, value=value)
def tearDownClass(cls): cls.network.stop() Settings.default_settings()
def setUpClass(cls): Settings.default_settings() cls.node_names = ["Alice", "Bob", "Charlie"] cls.network = Network(cls.node_names) cls.network.start()
def max_qubits(value): """Max virt-qubits per node and max sim-qubits per register.""" Settings.set_setting("BACKEND", "maxqubits_per_node", str(value))
def backend(value): """The backend to use (stabilizer, projectq, qutip).""" Settings.set_setting("BACKEND", "backend", value)
def default(): """Sets all settings back to default""" Settings.default_settings()
def tearDownClass(cls): cls.alice.close() cls.bob.close() cls.network.stop() Settings.default_settings()
def construct_topology_config(topology, nodes, save_fig=True): """ Constructs a json file at config/topology.json, used to define the topology of the network. :param topology: str Should be one of the following: None, 'complete', 'ring', 'random_tree'. :param nodes: list of str List of the names of the nodes. :param save_fig: bool Whether to save a picture of the network :return: None """ if topology: if isinstance(topology, dict): adjacency_dct = {node: topology[node] for node in nodes} elif topology == "complete": adjacency_dct = {} for i, node in enumerate(nodes): adjacency_dct[node] = nodes[:i] + nodes[i + 1:] elif topology == "ring": adjacency_dct = {} nn = len(nodes) for i, node in enumerate(nodes): adjacency_dct[node] = [ nodes[(i - 1) % nn], nodes[(i + 1) % nn] ] elif topology == "path": adjacency_dct = {} nn = len(nodes) for i, node in enumerate(nodes): if i == 0: adjacency_dct[node] = [nodes[i + 1]] elif i == (nn - 1): adjacency_dct[node] = [nodes[i - 1]] else: adjacency_dct[node] = [ nodes[(i - 1) % nn], nodes[(i + 1) % nn] ] elif topology == "random_tree": adjacency_dct = get_random_tree(nodes) elif topology[:16] == "random_connected": try: nr_edges = int(topology[17:]) except ValueError: raise ValueError( "When specifying a random connected graph use the format 'random_connected_{nr_edges}'," "where 'nr_edges' is the number of edges of the graph.") except IndexError: raise ValueError( "When specifying a random connected graph use the format 'random_connected_{nr_edges}'," "where 'nr_edges' is the number of edges of the graph.") adjacency_dct = get_random_connected(nodes, nr_edges) else: raise ValueError("Unknown topology name") # Get path to SimulaQron folder simulaqron_path = get_simulaqron_path.main() if save_fig: network = nx.from_dict_of_lists(adjacency_dct) try: nx.draw(network, with_labels=True) except _tkinter.TclError as err: logging.warning( "Could not draw since there seems to be no screen. Error: {}" .format(err)) else: fig_path = os.path.join(simulaqron_path, "config/topology.png") plt.savefig(fig_path) topology_file = os.path.join(simulaqron_path, "config/topology.json") with open(topology_file, "w") as top_file: json.dump(adjacency_dct, top_file) Settings.set_setting("BACKEND", "topology_file", "config/topology.json") else: Settings.set_setting("BACKEND", "topology_file", "")
def conn_retry_time(value): """If setup fails, how long to wait until a retry.""" Settings.set_setting("BACKEND", "waittime", str(value))
def setUpClass(cls): cls.iterations = 8 Settings.default_settings() cls.network = Network(nodes=["Alice", "Bob"]) cls.network.start()
def recv_timeout(value): """When receiving a qubit or EPR pair, how long to wait until raising a timeout.""" Settings.set_setting("BACKEND", "recvtimeout", str(value)) Settings.set_setting("BACKEND", "recveprtimeout", str(value))
def setUpClass(cls): Settings.default_settings() cls.network = Network(nodes=["Alice"]) cls.network.start()
def recv_retry_time(value): """When receiving a qubit or EPR pair, how long to wait between checks of whether a qubit is received.""" Settings.set_setting("BACKEND", "waittimerecv", str(value))