Utils#
Collection of util functions.
- enum DocEnum(value)[source]#
Enumeration with documentation of its members. Taken directly from stack overflow.
- gini_coefficient(values: Iterable[int | float | mpq]) int | float | mpq [source]#
Returns the Gini coefficient of the vector of values given as argument.
- Parameters:
values (Iterable[Numeric]) – A vector of values.
- Returns:
The Gini coefficient.
- Return type:
Numeric
- mean_generator(generator: Iterable[int | float | mpq] | Iterable[tuple[int | float | mpq, int]]) int | float | mpq [source]#
Computes the mean of a sequence of numbers given as a generator. If the generator contains tuples, the first element is assumed to be the value and the second its multiplicity.
- Parameters:
generator (Iterable[Numeric] | Iterable[tuple[Numeric, int]) – The generator.
- Returns:
The mean of the values.
- Return type:
Numeric
- powerset(iterable: Iterable) Generator [source]#
Returns a generator of all the subsets of a given iterable.
- Parameters:
iterable (Iterable) – An iterable.
- Returns:
A generator of all the subsets of the iterable.
- Return type:
Generator
- Numeric#
Type for numeric values. Is the union of int, float and mpq fractions (from the gumpy2 package).
alias of
Union
[int
,float
,mpq
]