simulaqron.toolbox package

Submodules

simulaqron.toolbox.get_simulaqron_path module

simulaqron.toolbox.get_simulaqron_path.main()[source]

simulaqron.toolbox.has_module module

simulaqron.toolbox.has_module.main(module_name)[source]

simulaqron.toolbox.manage_nodes module

class simulaqron.toolbox.manage_nodes.NetworksConfigConstructor(file_path=None)[source]

Bases: object

add_network(node_names, network_name='default', topology=None)[source]

Adds a new network to the config, with some specified nodes.

Parameters
  • node_names – list of str Name of the nodes, e.g. [Alice, Bob]

  • network_name – str Name of the network (default: “default”)

  • topology – None or dict The topology of the network (optional) (default is fully connected)

add_node(node_name, network_name='default', app_hostname=None, cqc_hostname=None, vnode_hostname=None, app_port=None, cqc_port=None, vnode_port=None, neighbors=None)[source]

Adds a node with the given name to a network (default: “default”). If hostnames are None they will default to ‘localhost’. If the port numbers None, unused ones will be chosen between 8000 and 9000. If neighbors are specified a restricted topology can be constructed (default is fully connected).

Parameters
  • node_name – str Name of the node, e.g. Alice

  • network_name – str Name of the network (default: “default”)

  • app_hostname – str or None Hostname, e.g. localhost (default) or 192.168.0.1

  • cqc_hostname – str or None Hostname, e.g. localhost (default) or 192.168.0.1

  • vnode_hostname – str or None Hostname, e.g. localhost (default) or 192.168.0.1

  • app_port – int or None Port number for the application

  • cqc_port – int or None Port number for the cqc server

  • vnode_port – int or None Port number for the virtual node

  • neighbors – (list of str) or None A list of neighbors, of this node. If None all current nodes in the network will be adjacent to the added node.

Returns

None

get_node_names(network_name='default')[source]

Returns the names of the nodes in a network.

Parameters

network_name – str Name of the network (default: “default”)

Returns

list of str

get_nodes(network_name='default')[source]

Returns the node-config objects (_NodeConfig) in a network.

Parameters

network_name – str Name of the network (default: “default”)

Returns

list of _NodeConfig

read_from_file(file_path=None)[source]

Reads config from a file.

Parameters

file_path – None or str If a file_path was specified upon __init__ this will be used if file_path is None.

remove_network(network_name='default')[source]

Removes a network from the config.

Parameters

network_name – str Name of the network (default: “default”)

remove_node(node_name, network_name='default')[source]

Removes a node from the network.

Parameters
  • node_name – str Name of the node, e.g. Alice

  • network_name – str Name of the network (default: “default”)

reset()[source]

Resets the current object to a single network (“default”) with the nodes Alice, Bob, Charlie, David and Eve. Note that this does not overwrite any config file but can be done by calling ‘write_to_file’. :return:

to_dict()[source]

Constructs a dictionary with all the content that can be written to a json file :return: dict

write_to_file(file_path=None)[source]

Writes the content of this config to a file.

Parameters

file_path – None or str If a file_path was specified upon __init__ this will be used if file_path is None.

simulaqron.toolbox.reset module

simulaqron.toolbox.reset.main()[source]

simulaqron.toolbox.stabilizerStates module

class simulaqron.toolbox.stabilizerStates.StabilizerState(data=None, check_symplectic=True)[source]

Bases: object

Pauli2bool = {'I': (False, False), 'X': (True, False), 'Y': (True, True), 'Z': (False, True)}
static Pauli_phase_tracking(old_pauli, applied_pauli)[source]
add_qubit()[source]

Appends a qubit in the state |0> to the current state :return: None

apply_CNOT(control, target)[source]

Applies CNOT using qubit ‘control’ as control and ‘target’ as target. :param control: The control qubit :type control: int :param target: The target qubit :type control: int :return: None

apply_CZ(control, target)[source]

Applies CZ using qubit ‘control’ as control and ‘target’ as target. :param control: The control qubit :type control: int :param target: The target qubit :type control: int :return: None

apply_H(position)[source]

Applies the H operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_K(position)[source]

Applies the K operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_S(position)[source]

Applies the S operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_X(position)[source]

Applies the Pauli X operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_Y(position)[source]

Applies the Pauli Y operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_Z(position)[source]

Applies the Pauli Z operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_sqrt_IZ(position)[source]
apply_sqrt_minIX(position)[source]
bool2Pauli = {(False, False): 'I', (False, True): 'Z', (True, False): 'X', (True, True): 'Y'}
bool2phase = {False: '+1', True: '-1'}
static boolean_gaussian_elimination(matrix, return_pivot_columns=False)[source]

Given a boolean matrix returns the matrix in row reduced echelon form where entries are seen as elements of GF(2), i.e. intergers modulus 2. :param matrix: The boolean matrix :type matrix: numpy.array :return: :rtype: numpy.array

check_symplectic()[source]
contains(stabilizer)[source]

Checks if a given stabilizer is in the stabilizer group.

Args:

stabilizer (str or list): The stabilizer to check if it’s in the group.

Should either be a str of the form “XXX” or “+1XXX” or a boolean list of length 2*n or 2*n + 1 in the same way as the input to the __init__ of the class.

find_SQC_equiv_graph_state(return_operations=False)[source]

Finds a graph state single qubit Clifford equivalent to self. Method is described in quant-ph/0308151.

For example:

EPR_pair = [[1,1,0,0],[0,0,1,1]] S = StabilizerState(EPR_pair) G = find_SQC_equiv_graph_state(S)

Parameters

self (StabilizerState) – The StabilizerState for which we want to find the corresponding graph state

Returns

A networkx graph SQC equivalent to S

Return type

networkx.classes.graph.Graph

measure(position, inplace=False)[source]

Measures qubit ‘position’ of the stabilizer state in the standard basis. If ‘inplace=False’ the qubit is removed from the state, i.e. the number of qubits in the state is reduced by one If ‘inplace=True’ the qubit is not removed and the number of qubits remain the same. :param position: The position of the qubit. :type position: int :param inplace: Whether to measure the qubit in place or not. (I.e. to keep it or not) :type inplace: bool :return: The measurement outcome (0 or 1, where 0 is the +1 eigenvalue and 1 is the -1) :rtype: int

property num_qubits
phase2bool = {'+1': False, '-1': True}
put_in_standard_form()[source]

Puts the generators of the stabilizer group in standard form by performing Gaussiand elemination :return: None

tensor_product(other)[source]

Performs the tensor product with another StabilizerState and returns a new StabilizerState.

This can also be done using ‘*’ as for example:

s1 = StabilizerState([[0, 1]]) # The state |0> s2 = StabilizerState([[0, 1]]) # The state |0>

s3 = s1 * s2 # This is then the state |00>

Parameters

other (StabilizerState) – The other StabilizerState to perform the tensor product with

Returns

The tensor product of self and other

Return type

StabilizerState

to_array(standard_form=False, return_pivot_columns=False)[source]

Returns the numpy array representing the stabilizer group of this state. See doc-string for __init__ how the elements of this numpy array are treated. Since, the __init__ takes an array as input, given a StabilizerState ‘s1’ on can do:

s2 = StabilizerState(to_array(s1))

and ‘s1’ and ‘s2’ will represent the same state.

Returns

The generators of this stabilizer group as a numpy array

Return type

numpy.array

to_string()[source]

Module contents