aerosandbox.tools.pretty_plots.labellines.utils
#
Module Contents#
Classes#
Functions#
|
Make sure datetime values are properly converted to floats. |
|
Finds the maximum bipartite matching of a graph |
|
If obj is iterable, return an iterator over its items: |
- aerosandbox.tools.pretty_plots.labellines.utils.ensure_float(value)[source]#
Make sure datetime values are properly converted to floats.
- aerosandbox.tools.pretty_plots.labellines.utils.maximum_bipartite_matching(graph)[source]#
Finds the maximum bipartite matching of a graph
- Parameters:
graph (np.ndarray) – The graph, represented as a boolean matrix
- Returns:
order – The order in which to traverse the graph to visit a maximum of nodes
- Return type:
np.ndarray
- aerosandbox.tools.pretty_plots.labellines.utils.always_iterable(obj, base_type=(str, bytes))[source]#
If obj is iterable, return an iterator over its items:
>>> obj = (1, 2, 3) >>> list(always_iterable(obj)) [1, 2, 3]
If obj is not iterable, return a one-item iterable containing obj:
>>> obj = 1 >>> list(always_iterable(obj)) [1]
If obj is
None
, return an empty iterable:>>> obj = None >>> list(always_iterable(None)) []
By default, binary and text strings are not considered iterable:
>>> obj = 'foo' >>> list(always_iterable(obj)) ['foo']
If base_type is set, objects for which
isinstance(obj, base_type)
returnsTrue
won’t be considered iterable.>>> obj = {'a': 1} >>> list(always_iterable(obj)) # Iterate over the dict's keys ['a'] >>> list(always_iterable(obj, base_type=dict)) # Treat dicts as a unit [{'a': 1}]
Set base_type to
None
to avoid any special handling and treat objects Python considers iterable as iterable:>>> obj = 'foo' >>> list(always_iterable(obj, base_type=None)) ['f', 'o', 'o']