loom.cliffordsim.classicalreg

Copyright (c) Entropica Labs Pte Ltd 2025.

Use, distribution and reproduction of this program in its source or compiled form is prohibited without the express written consent of Entropica Labs Pte Ltd.

class loom.cliffordsim.classicalreg.ClassicalRegister(name, no_of_bits, bit_ids=None)[source]

Bases: object

A register that stores classical bits that can be accessed at runtime by the Engine.

Comments: Consider Big Registry Design with Smaller Classical Registers as Views. Similar design to Tableau where all quantum data is in a Tableau.

Parameters:
  • name (str) – The name of this classical register.

  • no_of_bits (int) – The number of bits the register will be initialized with.

  • bit_ids (Optional[list[str]]) – A list containing the ids of every bit in the classical register. The ids provided do not have to be uuid compatible but must be of equal length to the number of bits. If the bit ids are not provided, the bits will be initialized with randomized ids generated using uuid4.

property bit_ids: list[str]

The bit IDs of all the bits in the classical register.

property bit_reg: list[int]

The bit values of all the bits in the classical register.

create_snapshot()[source]

Creates a ClassicalRegisterSnapshot object, a snapshot of the state of the ClassicalRegister, that contains important properties of the ClassicalRegister.

The ClassicalRegisterSnapshot object can then be used to restore the state of the ClassicalRegister at the time the snapshot was created.

Return type:

ClassicalRegisterSnapshot

property id_bit_reg: dict[str, int]

A dictionary whose key, value pairs are the bit IDs and their respective bit values.

property no_of_bits: int

The total number of bits in the current classical register.

property reg: list[tuple[str, int]]

The classical register represented as a list of tuples whose first entry is the ID of the bit and the second entry is the value of the bit.

classmethod restore(cr_snapshot)[source]

This method allows us to restore the state of the ClassicalRegister with a ClassicalRegisterSnapshot Object. The method returns an initialized ClassicalRegister with the Snapshot state.

Return type:

ClassicalRegister

class loom.cliffordsim.classicalreg.ClassicalRegisterSnapshot(name, no_of_bits, reg)[source]

Bases: object

A snapshot of the classical register at a specific point in time.

name: str
no_of_bits: int
reg: list[tuple[str, int]]