Logarithmics

class Logarithmic(value, value_type=ValueType.DB, conversion=DbConversionType.POWER)[source]

Bases: float

Representation of a logarithmic number.

Logarithmic numbers represent Decibel (dB) parameters within Hermes’ API. However, they will always act as their linear value when being interacted with, in order to preserve compatibility with any internal equation, since equations internally assume all parameters to be linear.

Note that therefore,

a = Logarithmic(10)
b = Logarithmic(20)

c = a + b
print(c)
>>> 20dB

will return in the output \(20.41392685158225\) instead of \(30\), since internally the linear representations will be summed. Instead, use the multiplication operator to sum Logarithmics, i.e.

a = Logarithmic(10)
b = Logarithmic(20)

c = a * b
print(c)
>>> 30dB
Parameters:
  • value (Union[float, int]) – Value of the logarithmic number.

  • value_type (ValueType, optional) – Assumed type of value. Decibels by default.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

classmethod From_Tuple(linear, logarithmic, conversion=DbConversionType.POWER)[source]
Return type:

Logarithmic

property conversion: DbConversionType

Logarithmic conversion type.

Returns: Conversion type.

property value_db: float

Logarithmic value of represented number.

Returns: Logarithmic value.

class LogarithmicSequence(values: Sequence[float | int] | None = None, value_type: ValueType = ValueType.DB, conversion: DbConversionType = DbConversionType.POWER)[source]

Bases: ndarray

A sequence of logarithmic numbers.

Parameters:
  • values (Sequence[Union[float, int]], optional) – Initial content of the represented sequence. If not provided, the sequence will be initialized as empty.

  • value_type (ValueType, optional) – Assumed type of value. Decibels by default.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

tolist()[source]

Convert to list representation.

Returns: List of logarithmics.

Return type:

List[Logarithmic]

property conversion: DbConversionType

Logarithmic conversion type.

Returns: Conversion type.

class ValueType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

DB = 1

Logarithmic number.

LIN = 0

Linear number.

dB(*values, conversion=DbConversionType.POWER)[source]

Represent scalar value as logarithmic number.

Parameters:
  • *values (Tuple[Union[int, float]]) – Value or sequence of values to be represented as logarithmic.

  • conversion (DbConversionType, optional) – Conversion of logarithmic scale. Power by default.

Return type:

Union[Logarithmic, LogarithmicSequence]

Returns: The logarithmic representation of *values.