comyx.utils
#
Package Summary#
Functions#
|
Convert power in decibels to watts. |
|
Convert decibels relative to 1 milliwatt to watts. |
|
Ensure that the argument is a list of desired length. |
|
Generate a seed from an identifier. |
|
Calculate the Euclidean distance between two points. |
|
Inverse Q function. |
|
Compute the Laguerre polynomial. |
|
Convert power in watts to decibels. |
|
Convert power in watts to decibels relative to 1 milliwatt. |
|
Compute the Q function. |
|
Compute the rolling mean of a curve. |
|
Wrap an angle to the interval [0, 2 * pi]. |
Reference#
- comyx.utils.db2pow(db: float | NDArrayFloat) NDArrayFloat [source]#
Convert power in decibels to watts.
- Parameters:
db – Power in decibels.
- Returns:
Power in watts.
- comyx.utils.dbm2pow(dbm: float | NDArrayFloat) NDArrayFloat [source]#
Convert decibels relative to 1 milliwatt to watts.
- Parameters:
dbm – Power in decibels relative to 1 milliwatt.
- Returns:
Power in watts.
- comyx.utils.ensure_list(arg, length) List[Any] [source]#
Ensure that the argument is a list of desired length.
- Parameters:
arg – The argument to check.
length – The desired length of the list.
- Returns:
Argument repeated length times if it is not a list, otherwise the argument itself.
- comyx.utils.generate_seed(identifier: str) int [source]#
Generate a seed from an identifier.
Seed is generated using the MD5 hash of the identifier. The hash is then converted to an integer and the modulo operation is applied to ensure the seed fits into a 32-bit integer.
- Parameters:
identifier – The identifier to hash.
- Returns:
A seed for random number generation.
- comyx.utils.get_distance(pt1: List[Any], pt2: List[Any]) float [source]#
Calculate the Euclidean distance between two points.
Points must have the same dimension and be a list of length 2 or 3.
- Example usage:
>>> get_distance([0, 0], [1, 1]) 1.4142135623730951 >>> get_distance([0, 0, 0], [1, 1, 1]) 1.7320508075688772
- Parameters:
pt1 – The first point.
pt2 – The second point.
- Returns:
The Euclidean distance between the two points.
- comyx.utils.inverse_qfunc(x: float | NDArrayFloat) NDArrayFloat [source]#
Inverse Q function.
- Parameters:
x – Input to the inverse Q function.
- Returns:
Inverse Q function computed at x.
- comyx.utils.laguerre(x: float | NDArrayFloat, n: float) float | NDArrayFloat [source]#
Compute the Laguerre polynomial.
- Parameters:
x – Input to the Laguerre polynomial.
n – The order of the Laguerre polynomial.
- Returns:
Laguerre polynomial computed at x and order n.
- comyx.utils.pow2db(power: float | NDArrayFloat) NDArraySigned [source]#
Convert power in watts to decibels.
- Parameters:
power – Power in watts.
- Returns:
Power in decibels.
- comyx.utils.pow2dbm(power: float | NDArrayFloat) NDArraySigned [source]#
Convert power in watts to decibels relative to 1 milliwatt.
- Parameters:
pow – Power in watts.
- Returns:
Power in decibels relative to 1 milliwatt.
- comyx.utils.qfunc(x: float | NDArrayFloat) NDArrayFloat [source]#
Compute the Q function.
- Parameters:
x – Input to the Q function.
- Returns:
Q function computed at x.