plastid.util.services.lists module¶
Tools for manipulating lists
Methods¶
flatten_nested_lists_to_generator()
Flatten nested lists, from left-to-right and top-to-bottom, into a generator
flatten_nested_lists_to_list()
Flatten nested lists, from left-to-right and top-to-bottom, into a list
parse_list()
Parse string representation of list into a list of parsed data (e.g. a list of numbers, a list of strings, et c)
- plastid.util.services.lists.flatten_nested_lists_to_generator(l)[source]¶
Flatten a tree of nested lists into a generator, from left-to-right and top-to-bottom.
- Parameters
- llist
A tree as a list of lists
- Yields
- object
Next item in flattened list
- plastid.util.services.lists.flatten_nested_lists_to_list(inp)[source]¶
Flatten a tree of lists into a single list of items, from left-to-right and top-to-bottom.
- Parameters
- inplist
A tree as a list of lists
- Returns
- list
flattened list
Notes
Tuples and other sequences will not be flattened. They will remain in their native types
- plastid.util.services.lists.parse_list(inp)[source]¶
Restore non-nested lists of Python primitives from string representation of list Additionally parses numpy.nan, numpy.inf, and -numpy.inf to correct values
- Parameters
- inpstr
String representation of list data
- Returns
- list
- Raises
- AssertionError
if String does not represent a list
Notes
Complex types like nested lists or tuples will not be processed, and may not be parsed correctly.