def test_group_in_packets(self): 'It groups an iterator in packets of items' packets = list(group_in_packets(range(4), 2)) assert packets == [(0, 1), (2, 3)] packets = [packet for packet in group_in_packets(range(5), 2)] assert packets == [(0, 1), (2, 3), (4, )] packets = list(group_in_packets([], 2)) assert packets == []
def test_group_in_packets(self): 'It groups an iterator in packets of items' packets = list(group_in_packets(range(4), 2)) assert packets == [(0, 1), (2, 3)] packets = [packet for packet in group_in_packets(range(5), 2)] assert packets == [(0, 1), (2, 3), (4,)] packets = list(group_in_packets([], 2)) assert packets == []
def _calc_range_for_var_density(variations, window, chunk_size): min_, max_ = None, None for stats in group_in_packets(calc_snp_density(variations, window), chunk_size): stats = array.array('I', stats) this_min = min(stats) if min_ is None or min_ > this_min: min_ = this_min this_max = max(stats) if max_ is None or max_ < this_max: max_ = this_max return min_, max_