pytket.unit_id

class pytket.unit_id.Bit

A handle to a bit

__init__(self, index: int) None
__init__(self, name: str) None
__init__(self, name: str, index: int) None
__init__(self, name: str, row: int, col: int) None
__init__(self, name: str, index: collections.abc.Sequence[int]) None

Overloaded function.

  1. __init__(self, index: int) -> None

Constructs an id for some index in the default classical register

Parameters:

index – The index in the register

  1. __init__(self, name: str) -> None

Constructs a named id (i.e. corresponding to a singleton register)

Parameters:

name – The readable name for the id

  1. __init__(self, name: str, index: int) -> None

Constructs an indexed id (i.e. corresponding to an element in a linear register)

Parameters:
  • name – The readable name for the register

  • index – The numerical index

  1. __init__(self, name: str, row: int, col: int) -> None

Constructs a doubly-indexed id (i.e. corresponding to an element in a grid register)

Parameters:
  • name – The readable name for the register

  • row – The row index

  • col – The column index

  1. __init__(self, name: str, index: collections.abc.Sequence[int]) -> None

Constructs an id with an arbitrary-dimensional index

Parameters:
  • name – The readable name for the register

  • index – The index vector

from_list(arg: list, /) pytket.unit_id.Bit

Construct Bit instance from JSON serializable list representation of the Bit.

to_list(self) list

Return a JSON serializable list representation of the Bit.

Returns:

list containing register name and index

class pytket.unit_id.BitRegister

Linear register of UnitID types.

__init__(self, name: str, size: int) None

Construct a new BitRegister.

Parameters:
  • name – Name of the register.

  • size – Size of register.

to_list(self) list[pytket.unit_id.Bit]
property name

Name of register.

property size

Size of register.

class pytket.unit_id.Node

A handle to a device node

__init__(self, index: int) None
__init__(self, name: str, index: int) None
__init__(self, name: str, row: int, col: int) None
__init__(self, name: str, row: int, col: int, layer: int) None
__init__(self, name: str, index: collections.abc.Sequence[int]) None

Overloaded function.

  1. __init__(self, index: int) -> None

Constructs an id for some index in the default physical register

Parameters:

index – The index in the register

  1. __init__(self, name: str, index: int) -> None

Constructs an indexed id (i.e. corresponding to an element in a linear register)

Parameters:
  • name – The readable name for the register

  • index – The numerical index

  1. __init__(self, name: str, row: int, col: int) -> None

Constructs a doubly-indexed id (i.e. corresponding to an element in a grid register)

Parameters:
  • name – The readable name for the register

  • row – The row index

  • col – The column index

  1. __init__(self, name: str, row: int, col: int, layer: int) -> None

Constructs a triply-indexed id (i.e. corresponding to an element in a 3D grid register)

Parameters:
  • name – The readable name for the register

  • row – The row index

  • col – The column index

  • layer – The layer index

  1. __init__(self, name: str, index: collections.abc.Sequence[int]) -> None

Constructs an id with an arbitrary-dimensional index

Parameters:
  • name – The readable name for the register

  • index – The index vector

from_list(arg: list, /) pytket.unit_id.Node

Construct Node instance from JSON serializable list representation of the Node.

to_list(self) list
Returns:

a JSON serializable list representation of the Node

class pytket.unit_id.Qubit

A handle to a qubit

__init__(self, index: int) None
__init__(self, name: str) None
__init__(self, name: str, index: int) None
__init__(self, name: str, row: int, col: int) None
__init__(self, name: str, index: collections.abc.Sequence[int]) None

Overloaded function.

  1. __init__(self, index: int) -> None

Constructs an id for some index in the default qubit register

Parameters:

index – The index in the register

  1. __init__(self, name: str) -> None

Constructs a named id (i.e. corresponding to a singleton register)

Parameters:

name – The readable name for the id

  1. __init__(self, name: str, index: int) -> None

Constructs an indexed id (i.e. corresponding to an element in a linear register)

Parameters:
  • name – The readable name for the register

  • index – The numerical index

  1. __init__(self, name: str, row: int, col: int) -> None

Constructs a doubly-indexed id (i.e. corresponding to an element in a grid register)

Parameters:
  • name – The readable name for the register

  • row – The row index

  • col – The column index

  1. __init__(self, name: str, index: collections.abc.Sequence[int]) -> None

Constructs an id with an arbitrary-dimensional index

Parameters:
  • name – The readable name for the register

  • index – The index vector

from_list(arg: list, /) pytket.unit_id.Qubit

Construct Qubit instance from JSON serializable list representation of the Qubit.

to_list(self) list
Returns:

a JSON serializable list representation of the Qubit

class pytket.unit_id.QubitRegister

Linear register of UnitID types.

__init__(self, name: str, size: int) None

Construct a new QubitRegister.

Parameters:
  • name – Name of the register.

  • size – Size of register.

to_list(self) list[pytket.unit_id.Qubit]
property name

Name of register.

property size

Size of register.

class pytket.unit_id.UnitID

A handle to a computational unit (e.g. qubit, bit)

__init__(self) None
property index

Index vector describing position in the register. The length of this vector is the dimension of the register

property reg_name

Readable name of register

property type

Type of unit, either UnitType.qubit or UnitType.bit or UnitType.wasmstate

enum pytket.unit_id.UnitType(value)

Enum for data types of units in circuits (e.g. Qubits vs Bits).

Valid values are as follows:

qubit = UnitType.qubit

A single Qubit

wasmstate = UnitType.wasmstate

A single WasmState

bit = UnitType.bit

A single classical Bit

class pytket.unit_id.WasmState

A handle to a wasmstate

__init__(self, index: int) None

Constructs an id for some index in the default wasm register

Parameters:

index – The index in the register

from_list(arg: list, /) pytket.unit_id.WasmState

Construct WasmState instance from JSON serializable list representation of the WasmState.

to_list(self) list

Return a JSON serializable list representation of the WasmState.

Returns:

list containing register name and index