Iterables¶
manimlib/utils/iterables.py
这个文件中主要实现了和列表字典处理有关的函数
-
manimlib.utils.iterables.
remove_list_redundancies
(l)¶ Used instead of list(set(l)) to maintain order Keeps the last occurance of each element
对列表l去重,保留重复元素最后一次出现
-
manimlib.utils.iterables.
list_update
(l1, l2)¶ Used instead of list(set(l1).update(l2)) to maintain order, making sure duplicates are removed from l1, not l2.
从l1中删除l2中重复项,再与l2合并
-
manimlib.utils.iterables.
list_difference_update
(l1, l2)¶
返回两列表中不同的项的列表
-
manimlib.utils.iterables.
all_elements_are_instances
(iterable, Class)¶
iterable列表中的所有元素是否都为Class类
-
manimlib.utils.iterables.
adjacent_n_tuples
(objects, n)¶
objects的相邻n元组(返回zip)
-
manimlib.utils.iterables.
adjacent_pairs
(objects)¶
objects相邻对
-
manimlib.utils.iterables.
batch_by_property
(items, property_func)¶ 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)
-
manimlib.utils.iterables.
tuplify
(obj)¶
根据obj返回元组
若obj为str类型,返回(obj, )
尝试返回tuple(obj)
若报错,返回(obj, )
-
manimlib.utils.iterables.
stretch_array_to_length
(nparray, length)¶
将nparray扩展至length长度
-
manimlib.utils.iterables.
make_even
(iterable_1, iterable_2)¶
将iterable_1和iterable_2调成一样的长度,不足的伸缩调整
-
manimlib.utils.iterables.
make_even_by_cycling
(iterable_1, iterable_2)¶
将iterable_1和iterable_2调成一样的长度,不足的循环使用
-
manimlib.utils.iterables.
remove_nones
(sequence)¶
将sequence中的None去除掉,并返回
-
manimlib.utils.iterables.
concatenate_lists
(*list_of_lists)¶
串联列表list_of