surface_sim.layouts.Layout#

class Layout(setup)[source]#

Layout class for a QEC code.

Notes

The parameters of the layout must be updated or set by the appropiate methods of this class to guarantee a correct behavior. In this sense, the qubits and their connections cannot be updated once the layout object has been created.

__init__(setup)[source]#

Initiailizes the layout for a particular code.

Parameters:
setup

The layout setup, provided as a dict.

The setup dictionary is expected to have a ‘layout’ item, containing a list of dictionaries. Each such dictionary (dict[str, object]) must define the qubit label (str) corresponding the 'qubit' item. In addition, each dictionary must also have a 'neighbors' item that defines a dictonary (dict[str, str]) of ordinal directions and neighbouring qubit labels. Apart from these two items, each dictionary can hold any other metadata or parameter relevant to these qubits.

In addition to the layout list, the setup dictionary can also optionally define the name of the layout (str), a description (str) of the layout as well as the interaction order of the different types of check, if the layout is used for a QEC code.

Raises:
ValueError

If the type of the setup provided is not a dictionary.

Methods

adjacency_matrix()

Returns the adjaceny matrix corresponding to the layout.

expansion_matrix()

Returns the expansion matrix corresponding to the layout.

from_dict(setup)

Loads the layout class from a dictionary.

from_yaml(filename)

Loads the layout class from a YAML file.

get_coords(qubits)

Returns the coordinates of the given qubits.

get_inds(qubits)

Returns the indices of the qubits.

get_label_from_ind(ind)

Returns the qubit label for the given qubit index.

get_labels_from_inds(inds)

Returns list of qubit labels for the given qubit indicies.

get_logical_inds(logical_qubits)

Returns the indices of the specified logical qubits.

get_logical_labels_from_inds(inds)

Returns list of logical qubit labels for the given logical qubit indicies.

get_max_ind()

Returns the largest qubit index in the layout.

get_max_logical_ind()

Returns the largest logical qubit index in the layout.

get_min_ind()

Returns the smallest qubit index in the layout.

get_min_logical_ind()

Returns the largest logical qubit index in the layout.

get_neighbors(qubits, *[, as_pairs])

Returns the list of qubit labels, neighboring specific qubits that meet a set of conditions.

get_qubits(**conds)

Return the qubit labels that meet a set of conditions.

get_support(qubits)

Returns a dictionary mapping the qubits to their support.

logical_param(param[, logical_qubit])

Returns the parameter value of a given logical qubit.

observable_definition(observable)

Returns the definition of the specified observable.

param(param, qubit)

Returns the parameter value of a given qubit

projection_matrix(stab_type)

Returns the projection matrix, mapping data qubits (defined by a parameter 'role' equal to 'data') to ancilla qubits (defined by a parameter 'role' equal to 'anc') measuing a given stabilizerr type (defined by a parameter 'stab_type' equal to stab_type).

set_logical_param(param, logical_qubit, value)

Sets the valur of a given logical parameter.

set_param(param, qubit, value)

Sets the value of a given qubit parameter

to_dict()

Return a setup dictonary for the layout.

to_yaml(filename)

Saves the layout as a YAML file.

Attributes

__init__(setup)

Initiailizes the layout for a particular code.

adjacency_matrix()

Returns the adjaceny matrix corresponding to the layout.

expansion_matrix()

Returns the expansion matrix corresponding to the layout.

from_dict(setup)

Loads the layout class from a dictionary.

from_yaml(filename)

Loads the layout class from a YAML file.

get_coords(qubits)

Returns the coordinates of the given qubits.

get_inds(qubits)

Returns the indices of the qubits.

get_label_from_ind(ind)

Returns the qubit label for the given qubit index.

get_labels_from_inds(inds)

Returns list of qubit labels for the given qubit indicies.

get_logical_inds(logical_qubits)

Returns the indices of the specified logical qubits.

get_logical_labels_from_inds(inds)

Returns list of logical qubit labels for the given logical qubit indicies.

get_max_ind()

Returns the largest qubit index in the layout.

get_max_logical_ind()

Returns the largest logical qubit index in the layout.

get_min_ind()

Returns the smallest qubit index in the layout.

get_min_logical_ind()

Returns the largest logical qubit index in the layout.

get_neighbors(qubits, *[, as_pairs])

Returns the list of qubit labels, neighboring specific qubits that meet a set of conditions.

get_qubits(**conds)

Return the qubit labels that meet a set of conditions.

get_support(qubits)

Returns a dictionary mapping the qubits to their support.

logical_param(param[, logical_qubit])

Returns the parameter value of a given logical qubit.

observable_definition(observable)

Returns the definition of the specified observable.

param(param, qubit)

Returns the parameter value of a given qubit

projection_matrix(stab_type)

Returns the projection matrix, mapping data qubits (defined by a parameter 'role' equal to 'data') to ancilla qubits (defined by a parameter 'role' equal to 'anc') measuing a given stabilizerr type (defined by a parameter 'stab_type' equal to stab_type).

set_logical_param(param, logical_qubit, value)

Sets the valur of a given logical parameter.

set_param(param, qubit, value)

Sets the value of a given qubit parameter

to_dict()

Return a setup dictonary for the layout.

to_yaml(filename)

Saves the layout as a YAML file.