loom.eka.utilities.enums
Copyright 2024 Entropica Labs Pte Ltd
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class loom.eka.utilities.enums.BoolOp(*values)[source]
Bases:
str,EnumBoolOp enum to specify operations on channels. Used in the “name” field of Circuit to indicate classical logic operations.
It is understood that AND, NAND, OR, NOR, and XOR can correspond to operations that reduce multiple bits to a single bit, while MATCH and NOT correspond to an operation on one bit only.
AND -> True when all channels are 1 NAND -> True when at least one channel is 0 OR -> True when at least one channel is 1 NOR -> True when all channels are 0 XOR -> True when an odd number of channels are 1
NOT -> True when the channel is 0 MATCH -> True when the channel is 1
- AND = 'and'
- MATCH = 'match'
- NAND = 'nand'
- NOR = 'nor'
- NOT = 'not'
- OR = 'or'
- XOR = 'xor'
- class loom.eka.utilities.enums.DiagonalDirection(*values)[source]
Bases:
str,EnumDiagonal 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:
- classmethod from_directions(directions)[source]
Get the diagonal direction from two cardinal directions. The two directions must be perpendicular.
- Return type:
- 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:
- mirror_across_orientation(orientation)[source]
Get the mirrored diagonal direction across the given orientation.
- Return type:
- class loom.eka.utilities.enums.Direction(*values)[source]
Bases:
str,EnumDirection 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:
- mirror_across_orientation(orientation)[source]
Get the mirrored direction across the given orientation.
- Return type:
- class loom.eka.utilities.enums.Orientation(*values)[source]
Bases:
str,EnumOrientation indicator for Operations (e.g. Split) and for Block initialization.
- HORIZONTAL = 'horizontal'
- VERTICAL = 'vertical'
- 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:
- class loom.eka.utilities.enums.ResourceState(*values)[source]
Bases:
str,EnumSupported states in state injection operations.
- S = 's'
- T = 't'
- class loom.eka.utilities.enums.SingleQubitPauliEigenstate(*values)[source]
Bases:
str,EnumSupported 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.