Utilities¶
Various utility functions.
API Reference¶
-
uncertainpy.utils.utility.
contains_nan
(values)[source]¶ Checks if
None
ornumpy.nan
exists in values. ReturnsTrue
if any there are at least one occurrence ofNone
ornumpy.nan
.Parameters: values (array_like, list, number) – values where to check for occurrences of None
ornp.nan
. Can be irregular and have any number of nested elements.Returns: True
if values has at least one occurrence ofNone
ornumpy.nan
.Return type: bool
-
uncertainpy.utils.utility.
is_regular
(values)[source]¶ Test if values is regular or not, meaning it has a varying length of nested elements.
Parameters: values (array_like, list, number) – values to check if it is regular or not, meaning it has a varying length of nested elements. Returns: True if the feature is regular or False if the feature is irregular. Return type: bool Notes
Does not ignore
numpy.nan
, so[numpy.nan, [1, 2]]
returns False.
-
uncertainpy.utils.utility.
lengths
(values)[source]¶ Get the lengths of a list and all its sublists.
Parameters: values (list) – List where we want to find the lengths of the list and all sublists. Returns: A list with the lengths of the list and all sublists. Return type: list
-
uncertainpy.utils.utility.
none_to_nan
(values)[source]¶ Converts
None
values in values tonp.nan
.Parameters: values (array_like, list, number) – Values where to convert occurrences of None
converted tonp.nan
. Can be irregular and have any number of nested elements.Returns: values – values with all occurrences of None
converted tonp.nan
.Return type: array_like, list, number
-
uncertainpy.utils.utility.
set_nan
(values, index)[source]¶ Set the index of a arbitrarly nested list to nan
Parameters: - values (array_like, list, number) – Values where to set index to
numpy.nan
. Can be irregular and have any number of nested elements. - index (array_like, list, number) – Index where to set values to
numpy.nan
.
- values (array_like, list, number) – Values where to set index to