libera_utils.quality_flags#

Quality flag definitions

Functions

with_all_none(f)

Decorator that adds NONE and ALL psuedo-members to a QualityFlag f

Classes

FlagBit(*args[, message])

Subclass of int to capture both an integer value and an accompanying message

FrozenFlagMeta(name, bases, classdict)

Metaclass that freezes an enum entirely, preventing values from being updated, added, or deleted.

QualityFlag(value[, names, module, ...])

Subclass of Flag that add a method for decomposing a flag into its individual components and a property to return a list of all messages associated with a quality flag

class libera_utils.quality_flags.FlagBit(*args, message=None, **kwargs)#

Subclass of int to capture both an integer value and an accompanying message

Attributes:
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

Methods

as_integer_ratio(/)

Return integer ratio.

bit_count(/)

Number of ones in the binary representation of the absolute value of self.

bit_length(/)

Number of bits necessary to represent self in binary.

conjugate

Returns self, the complex conjugate of any int.

from_bytes(/, bytes[, byteorder, signed])

Return the integer represented by the given array of bytes.

to_bytes(/[, length, byteorder, signed])

Return an array of bytes representing an integer.

class libera_utils.quality_flags.FrozenFlagMeta(name, bases, classdict)#

Metaclass that freezes an enum entirely, preventing values from being updated, added, or deleted.

Methods

__call__(value[, names, module])

Either returns an existing member, or creates a new enum class.

mro(/)

Return a type's method resolution order.

class libera_utils.quality_flags.QualityFlag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Subclass of Flag that add a method for decomposing a flag into its individual components and a property to return a list of all messages associated with a quality flag

libera_utils.quality_flags.with_all_none(f)#

Decorator that adds NONE and ALL psuedo-members to a QualityFlag f

For example:

@with_all_none
class MyQualityFlag(QualityFlag, metaclass=FrozenFlagMeta):
    MISSING_DATA = FlagBit(0b1, message="Data is missing!")
    VOLTAGE_TOO_HIGH = FlagBit(0b10, message="Voltage is too high!")
qf = MyQualityFlag.ALL  # Equivalent to MyQualityFlag(0b11)
qf.summary