edges.tools

Various utility functions.

class edges.tools.ComplexSpline(x, y, **kwargs)[source]

Return a complex spline object.

edges.tools.as_readonly(x: ndarray) ndarray[source]

Get a read-only view into an array without copying.

edges.tools.dct_of_list_to_list_of_dct(dct: dict[str, Sequence]) list[dict][source]

Take a dict of key: list pairs and turn it into a list of all combos of dicts.

Parameters:

dct – A dictionary for which each value is an iterable.

Returns:

list – A list of dictionaries, each having the same keys as the input dct, but in which the values are the elements of the original iterables.

Examples

>>> dct_of_list_to_list_of_dct(
>>>    { 'a': [1, 2], 'b': [3, 4]}
[
    {"a": 1, "b": 3},
    {"a": 1, "b": 4},
    {"a": 2, "b": 3},
    {"a": 2, "b": 4},
]
edges.tools.decibels_to_linear(x: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[float]][source]

Convert a number in decibels to linear.

edges.tools.join_struct_arrays(arrays)[source]

Join a list of structured numpy arrays (make new columns).

edges.tools.linear_to_decibels(x: ndarray[tuple[Any, ...], dtype[_ScalarT]]) ndarray[tuple[Any, ...], dtype[float]][source]

Convert a linear number to decibels.

edges.tools.slice_along_axis(x: ndarray, idx: ndarray | slice, axis: int = -1)[source]

Get a view of x at indices idx on a given axis.

edges.tools.stable_hash(x) str[source]

A simple hash function to string.