In [1]:
from ahh import ext

In [2]:
list_in_list = [[1, 2, 3, 4]]
ext.flatten(list_in_list) # remove extra layer of list
# equivalent to:
list_in_list[0]


Out[2]:
[1, 2, 3, 4]
Out[2]:
[1, 2, 3, 4]

In [3]:
lists_in_list = [[1, 2, 3, 4], [4, 5]]
ext.flatten(lists_in_list) # but most useful if you want to remove extra layer and combine the lists within


Out[3]:
[1, 2, 3, 4, 4, 5]

In [4]:
lists_in_list = [[2, 3, 4], [4, 5], [4, 4], [235], [231], [111]]
ext.flatten(lists_in_list) # just another example


Out[4]:
[2, 3, 4, 4, 5, 4, 4, 235, 231, 111]

In [5]:
lists_in_list = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0]
ext.split_consec(lists_in_list) # break list into sections where consecutive


Out[5]:
[array([0, 0]), array([1, 1, 1]), array([0, 0, 0, 0]), array([1]), array([0])]

In [6]:
lists_in_list = [3, 3, 4, 4, 4, 5, 5, 5, 5, 2, 2]
ext.split_consec(lists_in_list) # another example


Out[6]:
[array([3, 3]), array([4, 4, 4]), array([5, 5, 5, 5]), array([2, 2])]

In [ ]: