sampo.utilities.collections_util#

Overview#

Function#

flatten(xs)

Returns a generator which should flatten any heterogeneous iterable

build_index(items, key_getter, value_getter)

param items:

an iterable to index

reverse_dictionary(dictionary)

-

Attributes#

T

-

K

-

V

-

Functions#

sampo.utilities.collections_util.flatten(xs: collections.abc.Iterable[list[T] | T]) collections.abc.Iterable[T]#

Returns a generator which should flatten any heterogeneous iterable

Parameters:

xs

Returns:

sampo.utilities.collections_util.build_index(items: collections.abc.Iterable[T], key_getter: Callable[[T], K], value_getter: Callable[[T], V] = lambda x: ...) dict[K, V]#
Parameters:
  • items – an iterable to index

  • key_getter – a function that should retrieve index key from item

  • value_getter – a function that should retrieve index value from item

Returns:

dictionary that represents built index given by key_getter function

sampo.utilities.collections_util.reverse_dictionary(dictionary: dict[K, V]) dict[V, K]#

Attributes#

sampo.utilities.collections_util.T#
sampo.utilities.collections_util.K#
sampo.utilities.collections_util.V#