abtem.core.utils#
Module for various convenient utilities.
Module Contents#
Classes#
Functions#
Cosine and sine of an angle given in degrees. |
|
Expand the dimensions of two arrays to make them broadcastable. |
|
Flatten a list of lists into a single list. |
|
Get the numpy dtype from the config precision setting. |
|
Interleave two lists or tuples. |
|
Check if the value is a float, int, or a NumPy scalar. |
|
Returns a generator that yields indices for each label in the labels array. |
|
Normalize the axes tuple so that all axes are non-negative. |
|
Data#
API#
- abtem.core.utils.T#
‘TypeVar(…)’
- abtem.core.utils.cos_sin_deg(...) tuple[float, float][source]#
Cosine and sine of an angle given in degrees.
- abtem.core.utils.expand_dims_to_broadcast(...) tuple[ndarray | dask.array.core.Array, ndarray | dask.array.core.Array][source]#
Expand the dimensions of two arrays to make them broadcastable.
- Parameters:
arr1 (ndarray) – The first array.
arr2 (ndarray) – The second array.
match_dims (list, optional) – A list of two tuples, each containing the dimensions that should match (i.e. not be broadcasted) between the two arrays.
broadcast (bool, optional) – If True, broadcast the arrays to the same shape, otherwise only expand the dimensions. Defaults to False.
- Returns:
A tuple containing the expanded arrays.
- Return type:
- abtem.core.utils.flatten_list_of_lists(...) list[source]#
Flatten a list of lists into a single list.
- abtem.core.utils.get_dtype(...) dtype[source]#
Get the numpy dtype from the config precision setting.
- Parameters:
complex (bool, optional) – If True, return a complex dtype. Defaults to False.
- abtem.core.utils.is_scalar(...) TypeGuard[float | int | floating | integer][source]#
Check if the value is a float, int, or a NumPy scalar.
- Parameters:
value (any) – The value to check.
- Returns:
True if the value is a float, int, or a NumPy scalar, False otherwise.
- Return type:
- abtem.core.utils.label_to_index(...)[source]#
Returns a generator that yields indices for each label in the labels array.