pipeline.domain.measures.Frequency

class Frequency(value: int | float | Decimal = 0, units: dict = {'hz': Decimal('1E+9'), 'name': 'GIGAHERTZ', 'symbol': 'GHz'})[source]

Bases: ComparableUnit

Methods

convert_to

Converts this measure of frequency to the new units.

str_to_precision

Return the string representation of this Frequency to a fixed number of decimal places.

to_units

Returns the magnitude of this frequency in otherUnits.

Attributes

value

units

__init__(value: int | float | Decimal = 0, units: dict = {'hz': Decimal('1E+9'), 'name': 'GIGAHERTZ', 'symbol': 'GHz'}) None[source]

Creates a new frequency with the given magnitude and units.

If called without arguments, the constructor will create a default frequency of 0 gigahertz.

Parameters:
  • value -- The magnitude for this frequency.

  • units -- The new units for this frequency.

convert_to(newUnits: dict = {'hz': Decimal('1E+9'), 'name': 'GIGAHERTZ', 'symbol': 'GHz'}) Frequency[source]

Converts this measure of frequency to the new units.

After this method is complete this frequency will have units of newUnits and its value will have been converted accordingly.

Parameters:

newUnits -- The new units for this frequency; by default, it will convert the frequency to Gigahertz.

Returns:

this frequency. The reason for this return type is to allow code of this nature:

gigahertz = myFrequency.convert_to(FrequencyUnits.GIGAHERTZ)

str_to_precision(precision: int) str[source]

Return the string representation of this Frequency to a fixed number of decimal places.

Parameters:

precision -- Number of decimal places to use.

Returns:

String representation of this Frequency to fixed number of decimal places.

to_units(otherUnits: dict = {'hz': Decimal('1E+9'), 'name': 'GIGAHERTZ', 'symbol': 'GHz'}) Decimal[source]

Returns the magnitude of this frequency in otherUnits.

Note that this method does not alter the state of this frequency. Contrast this with convert_to(FrequencyUnits).

Parameters:

otherUnits -- The units in which to express this frequency's magnitude. If newUnits is None, it will be treated as FrequencyUnits.GIGAHERTZ.

Returns:

this frequency's value converted to otherUnits.