grelu.utils#
General utility functions
Functions#
|
|
|
|
|
|
|
|
|
Return a function to aggregate values. |
|
Return a function to compare two values. |
|
Return a function to transform the input. |
|
Convert various kinds of inputs into a list |
Module Contents#
- grelu.utils.np_log2fc(x: numpy.ndarray, y: numpy.ndarray) numpy.ndarray [source]#
- grelu.utils.get_aggfunc(func: str | Callable | None, tensor: bool = False) Callable [source]#
Return a function to aggregate values.
- Parameters:
func – A function or the name of a function. Supported names are “max”, “min”, “mean”, and “sum”. If a function is supplied, it will be returned unchanged.
tensor – If True, it is assumed that the inputs will be torch tensors. If False, it is assumed that the inputs will be numpy arrays.
- Returns:
The desired function.
- Raises:
NotImplementedError – If the input is neither a function nor a supported function name.
- grelu.utils.get_compare_func(func: str | Callable | None, tensor: bool = False) Callable [source]#
Return a function to compare two values.
- Parameters:
func – A function or the name of a function. Supported names are “subtract”, “divide”, and “log2FC”. If a function is supplied, it will be returned unchanged. func cannot be None.
tensor – If True, it is assumed that the inputs will be torch tensors. If False, it is assumed that the inputs will be numpy arrays.
- Returns:
The desired function.
- Raises:
NotImplementedError – If the input is neither a function nor a supported function name.
- grelu.utils.get_transform_func(func: str | Callable | None, tensor: bool = False) Callable [source]#
Return a function to transform the input.
- Parameters:
func – A function or the name of a function. Supported names are “log” and “log1p”. If None, the identity function will be returned. If a function is supplied, it will be returned unchanged.
tensor – If True, it is assumed that the inputs will be torch tensors. If False, it is assumed that the inputs will be numpy arrays.
- Returns:
The desired function.
- Raises:
NotImplementedError – If the input is neither a function nor a supported function name.
- grelu.utils.make_list(x: pandas.Series | numpy.ndarray | torch.Tensor | Sequence | int | float | str | None) list [source]#
Convert various kinds of inputs into a list
- Parameters:
x – An input value or sequence of values.
- Returns:
The input values in list format.