subgrounds.utils module

Utility module for Subgrounds

subgrounds.utils.flatten(t)
subgrounds.utils.identity(x)
subgrounds.utils.fst(tup)
subgrounds.utils.snd(tup)
subgrounds.utils.intersection(l1, l2, key=<function identity>, combine=<function <lambda>>)
subgrounds.utils.rel_complement(l1, l2, key=<function identity>)
subgrounds.utils.sym_diff(l1, l2, key=<function identity>)
subgrounds.utils.union(l1, l2, key=<function identity>, combine=<function <lambda>>)
subgrounds.utils.filter_none(items)
subgrounds.utils.loop_generator(items)
subgrounds.utils.repeat(value, n)
subgrounds.utils.extract_data(keys, data)
subgrounds.utils.flatten_dict(data, keys=[])

Takes a dictionary containing key-value pairs where all values are of type other than list and flattens it such that all key-value pairs in nested dictionaries are now at depth 1.

Parameters
  • data (dict) -- Dictionary containing non-list values

  • keys (list[str], optional) -- Keys of data if data is a nested dict (len(keys) == depth of data). Defaults to [].

Returns

Flat dictionary containing all key-value pairs in data and its nested dictionaries

Return type

dict

subgrounds.utils.contains_list(data)

Returns True if data contains a value of type list in its nested data and False otherwise

Parameters

data (dict | list | str | int | float | bool) -- Data

Returns

True if data contains a list, False otherwise

Return type

bool