iterables

Operations on iterables.

Functions

adjacent_n_tuples(objects, n)[source]
adjacent_pairs(objects)[source]
all_elements_are_instances(iterable, Class)[source]
batch_by_property(items, property_func)[source]

Takes in a list, and returns a list of tuples, (batch, prop) such that all items in a batch have the same output when put into property_func, and such that chaining all these batches together would give the original list (i.e. order is preserved)

concatenate_lists(*list_of_lists)[source]
list_difference_update(l1, l2)[source]
list_update(l1, l2)[source]

Used instead of list(set(l1).update(l2)) to maintain order, making sure duplicates are removed from l1, not l2.

listify(obj)[source]
make_even(iterable_1, iterable_2)[source]
make_even_by_cycling(iterable_1, iterable_2)[source]
remove_list_redundancies(lst)[source]

Used instead of list(set(l)) to maintain order Keeps the last occurrence of each element

remove_nones(sequence)[source]
resize_array(nparray, length)[source]
resize_preserving_order(nparray, length)[source]
resize_with_interpolation(nparray, length)[source]
stretch_array_to_length(nparray, length)[source]
tuplify(obj)[source]