partition_list#

caput.util.arraytools.partition_list(full_list: list, i: int, n: int, method: str = 'con') list[source]#

Partition a list into n pieces. Return the i th partition.

Parameters:
full_listlist

The full list to partition.

iint

The index of the partition to return.

nint

The number of partitions to create.

method{“con”, “alt”, “rand”}, optional

The method to use for partitioning. Options are:

  • “con”: contiguous partitions

  • “alt”: alternating partitions

  • “rand”: random partitions

Default is “con”.

Returns:
partitionlist

The i th partition of the list.