list

Utils for operating on lists.

Functions

list_closest_to_median

Return element from list that's closest to list mean.

val2list

Repeat val for repeat_time times and return the list or val if list/tuple.

val2tuple

Return tuple with min_len by repeating element at idx_repeat.

stats

Compute min, max, avg, std of vals.

list_closest_to_median(x)

Return element from list that’s closest to list mean.

Parameters:

x (List) –

Return type:

Any

stats(vals)

Compute min, max, avg, std of vals.

Parameters:

vals (List[float]) –

Return type:

Dict[str, float]

val2list(val, repeat_time=1)

Repeat val for repeat_time times and return the list or val if list/tuple.

Parameters:

val (List | Tuple | Any) –

Return type:

List

val2tuple(val, min_len=1, idx_repeat=-1)

Return tuple with min_len by repeating element at idx_repeat.

Parameters:
  • val (List | Tuple | Any) –

  • min_len (int) –

  • idx_repeat (int) –

Return type:

Tuple