<jupyter_start><jupyter_text>Load balancer<jupyter_code>load_balancer = cl.load_balanced_view()
async = load_balancer.map(parse_MAFs,
                          [pos for pos in get_blocks() if pos[0] == 1],
                          block=False, chunksize=3, ordered=True)
while not async.ready():
    print(len(async), async.progress)
    time.sleep(1)
print('Done')
result = async.get()
import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure(figsize=(16, 9))
ax = fig.add_subplot(111)
xs = [x * window_size for x in range(len(result))]
ax.plot(xs, [np.mean(vals) for vals in result])
ax.plot(xs, [(lambda x : np.percentile(x, 90) if len(x) > 0 else None)(vals) for vals in result], 'k-.')
ax.set_xlabel('Chromosome position')
ax.set_xlabel('Heterozygosity')
ax.set_title('Mean and 90th percentile Hz over %d windows for chromosome 1' % window_size)<jupyter_output>/home/tra/anaconda3/envs/book2/lib/python2.7/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)
/home/tra/anaconda3/envs/book2/lib/python2.7/site-packages/numpy/core/_methods.py:71: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
{'fraction_non_alphanumeric': 0.13801452784503632, 'fraction_numerical': 0.022598870056497175, 'mean_word_length': 4.43859649122807, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '395537', 'license': 'Apache-2.0', 'n_tokens_mistral': 462, 'n_tokens_neox': 440, 'n_words': 99, 'path': 'notebooks/08_Advanced/IPythonParallel.ipynb', 'repo_name': 'kevintheduu/bioinf-python', 'size': '1239'}