nessai.utils.structures
Utilities for manipulating python structures such as lists and dictionaries.
Module Contents
Functions
|
Replace (in place) an entry in a list with a given element. |
|
Return a subset of a set of arrays. |
|
Check for +/- infinity and NaNs in a structured array. |
|
Split an array into multiple sub-arrays of a specified chunksize. |
|
Return the indices that are not in input array given a size n |
- nessai.utils.structures.replace_in_list(target_list, targets, replacements)
Replace (in place) an entry in a list with a given element.
- Parameters:
- target_listlist
List to update
- targetslist
List of items to update
- replacementslist
List of replacement items
- nessai.utils.structures.get_subset_arrays(indices, *args)
Return a subset of a set of arrays.
Assumes all arrays are the same length.
- Parameters:
- indicesarray
Array of indices or boolean array of same length as input arrays
- argsarrays
Set of arrays to index.
- Returns:
- tuple
A tuple contain the corresponding array for each input array. The order is preserved.
- nessai.utils.structures.isfinite_struct(x, names=None)
Check for +/- infinity and NaNs in a structured array.
Returns a boolean per entry not per field (name).
- Parameters:
- xnp.ndarray
Structured array
- nameslist[str]
Names of the fields to include. If not specified, the names from the dtype of the structured array are used.
- Returns:
- np.ndarray
Array of booleans indicating if each entry in the array is finite (True) or not (False).
- nessai.utils.structures.array_split_chunksize(x, chunksize)
Split an array into multiple sub-arrays of a specified chunksize.
- Parameters:
- xnumpy.ndarray
Input array.
- chunksizeint
Chunksize into which to split the array.
- Returns:
- list
List of numpy arrays each with a maximum length given by the chunksize.
- nessai.utils.structures.get_inverse_indices(n, indices)
Return the indices that are not in input array given a size n