Layout

class Layout(input_dict=None)[source]

Two-ways dict to represent a Layout.

construct a Layout from a bijective dictionary, mapping virtual qubits to physical qubits

Methods

Layout.__getitem__(item)

Layout.__len__()

Layout.add(virtual_bit[, physical_bit])

Adds a map element between bit and physical_bit.

Layout.add_register(reg)

Adds at the end physical_qubits that map each bit in reg.

Layout.combine_into_edge_map(another_layout)

Combines self and another_layout into an “edge map”.

Layout.copy()

Returns a copy of a Layout instance.

Layout.from_dict(input_dict)

Populates a Layout from a dictionary.

Layout.from_intlist(int_list, *qregs)

Converts a list of integers to a Layout mapping virtual qubits (index of the list) to physical qubits (the list values).

Layout.from_qubit_list(qubit_list)

Populates a Layout from a list containing virtual qubits, Qubit or None.

Layout.generate_trivial_layout(*regs)

Creates a trivial (“one-to-one”) Layout with the registers in regs.

Layout.get_physical_bits()

Returns the dictionary where the keys are physical (qu)bits and the values are virtual (qu)bits.

Layout.get_registers()

Returns the registers in the layout [QuantumRegister(2, ‘qr0’), QuantumRegister(3, ‘qr1’)] :returns: A list of Register in the layout :rtype: List

Layout.get_virtual_bits()

Returns the dictionary where the keys are virtual (qu)bits and the values are physical (qu)bits.

Layout.order_based_on_type(value1, value2)

decides which one is physical/virtual based on the type.

Layout.reorder_bits(bits)

Given an ordered list of bits, reorder them according to this layout.

Layout.swap(left, right)

Swaps the map between left and right.