LightcurveDB Utility Module¶
- lightcurvedb.util.iter.chunkify(iterable, chunksize, fillvalue=None)¶
Chunkify an iterable into equal sized partitions. The last chunk yielded might contain leftovers and have a length less than specified. If a
fillvalueis specified then this value will be padded in the last chunk until it meets the chunksize requirement.- Parameters:
iterable (iterable) – Some iterable to chunkify into partitions
chunksize (integer) – The size of the returned partitions. Must be greater than 0 otherwise a
ValueErroris raised.fillvalue (any, optional) – If the last partition
length < chunksizethen right pad the partition with the fillvalue` until the wanted partition size is reached.
- Yields:
list – A partitioned list of length <= chunksize
- Raises:
ValueError – For chunksize < 1.
- lightcurvedb.util.iter.eq_partitions(iterable, n)¶
Create
npartitions and distribute the iterable as equally as possible between the partitions.- Parameters:
iterable (iterable) – Some iterable to partition into
nlistsn (int) – The number of partitions to create. Cannot be less than 1. If this number is greater than the number of items within the given iterable, then it is guaranteed that some lists will be empty.
- Raises:
ValueError – Raised if
nis less than 1.- Returns:
Returns a tuple of lists. The tuple is length of
n. The lists contained within will be variant in length.- Return type:
tuple