loom.eka.utilities.enums

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.eka.utilities.enums.DiagonalDirection(*values)[source]

Bases: str, Enum

Diagonal direction indicator for Operations (e.g. Grow and Shrink).

BOTTOM_LEFT = 'bottom-left'
BOTTOM_RIGHT = 'bottom-right'
TOP_LEFT = 'top-left'
TOP_RIGHT = 'top-right'
property components

Return the two cardinal directions composing this diagonal.

direction_along_orientation(orientation)[source]

Get the cardinal direction along the given orientation.

Return type:

Direction

classmethod from_directions(directions)[source]

Get the diagonal direction from two cardinal directions. The two directions must be perpendicular.

Return type:

DiagonalDirection

classmethod from_vector(vector)[source]

Get the diagonal direction from a 2D vector. The vector should have only two non-zero components in the first and the second dimension. The direction is determined by the sign of the components. The direction is returned as a DiagonalDirection enum.

Return type:

DiagonalDirection

mirror_across_orientation(orientation)[source]

Get the mirrored diagonal direction across the given orientation.

Return type:

DiagonalDirection

opposite()[source]

Get the opposite diagonal direction.

Return type:

DiagonalDirection

to_vector()[source]

Convert the diagonal direction to a 2D vector.

Return type:

tuple[int, int]

class loom.eka.utilities.enums.Direction(*values)[source]

Bases: str, Enum

Direction indicator for Operations (e.g. Grow and Shrink).

BOTTOM = 'bottom'
LEFT = 'left'
RIGHT = 'right'
TOP = 'top'
classmethod from_vector(vector, bottom_is_plus=True)[source]

Get the direction from a 2D vector. The vector should have only one non-zero component in the first or the second dimension. The direction is determined by the non-zero component. The direction is returned as a Direction enum.

Return type:

Direction

mirror_across_orientation(orientation)[source]

Get the mirrored direction across the given orientation.

Return type:

Direction

opposite()[source]

Get the opposite direction.

Return type:

Direction

to_orientation()[source]

Convert the direction to an orientation.

Return type:

Orientation

to_vector()[source]

Convert the direction to a 2D vector.

Return type:

tuple[int, int]

class loom.eka.utilities.enums.Orientation(*values)[source]

Bases: str, Enum

Orientation indicator for Operations (e.g. Split) and for Block initialization.

HORIZONTAL = 'horizontal'
VERTICAL = 'vertical'
classmethod from_direction(direction)[source]

Get the orientation from a direction.

Return type:

Orientation

classmethod from_vector(vector)[source]

Get the orientation from a 2D vector. The orientation is determined by the direction of the vector. The orientation is returned as an Orientation enum.

Return type:

Orientation

perpendicular()[source]

Get the perpendicular orientation.

Return type:

Orientation

class loom.eka.utilities.enums.ResourceState(*values)[source]

Bases: str, Enum

Supported states in state injection operations.

S = 's'
T = 't'
get_expectation_value(basis)[source]

Get the expectation value of the state in the Pauli basis of the state.

Return type:

float

class loom.eka.utilities.enums.SingleQubitPauliEigenstate(*values)[source]

Bases: str, Enum

Supported states in reset operations.

MINUS = '-'
MINUS_I = '-i'
ONE = '1'
PLUS = '+'
PLUS_I = '+i'
ZERO = '0'
property basis_expectation_value: int

Get the expectation value of the state in the Pauli basis of the state.

property pauli_basis: str

Get the Pauli basis of the state.

loom.eka.utilities.enums.enum_missing(cls, value)[source]

This method is called when value is not found in the Enum. This could be the case when the input is not lower case but its lower case version is in the Enum. Therefore value is first converted to lower-case and then compared to the values in the Enum.

If no match is found, an exception is raised. Also note that the exception message is more informative than the default one since we here include the allowed values.