<jupyter_start><jupyter_text>Import modules<jupyter_code>import numpy as np
import matplotlib as mpl
#mpl.use('Agg')
import matplotlib.pyplot as plt
import os
from IPython.display import Image
import matplotlib.animation as animation
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import multiprocessing as mp<jupyter_output><empty_output><jupyter_text>Define Functions<jupyter_code>def generate_data(x,y,n,t):
    value = (x/10)**2*(y/10) + (y/10)**2*(x/10)+t/n
    value = value %1 # Keep number between 0 and 1
    return value
def write_data(X,Y,nFiles,i,my_cmap):
    filename=("output/file%05d.png"%i)
    Z=generate_data(X,Y,nFiles,i)
    
    fig,ax=plt.subplots()
    plt.imshow(Z,cmap=my_cmap)
    ax.axis('off')
    plt.savefig(filename,dpi=300,bbox_inches='tight')
    #plt.show()
    plt.close()
    
    
def custom_colormap(filename):
    data=np.genfromtxt(filename,delimiter=',',dtype=None)
    my_cmap=mpl.colors.ListedColormap(data)
    return my_cmap
def display_plot(id):
    return Image(filename='output/file%05d.png'%id)<jupyter_output><empty_output><jupyter_text>Set parameters<jupyter_code>nFiles=60 # N Files to write
size=100   # Size of NxN matrix to plot
os.makedirs("output",exist_ok='True')
half_size=size/2
x_origin=0
y_origin=500
x=np.arange(x_origin-half_size,x_origin+half_size,1)
y=np.arange(y_origin-half_size,y_origin+half_size,1)
X,Y=np.meshgrid(x,y)
my_pastel=custom_colormap("colors.txt")
nWorkers=4<jupyter_output><empty_output><jupyter_text>Do some work, show the resulting image<jupyter_code>with mp.Pool(processes=nWorkers) as pool:
    for i in range(nFiles):
        write_data(X,Y,nFiles,i,my_pastel)<jupyter_output><empty_output><jupyter_text>Go through each image<jupyter_code>interact(display_plot,id=widgets.IntSlider(min=0,max=nFiles-1,step=1,value=nFiles/2) );<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13027426160337552, 'fraction_numerical': 0.019514767932489453, 'mean_word_length': 6.806584362139918, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '329192', 'license': 'CC0-1.0', 'n_tokens_mistral': 777, 'n_tokens_neox': 748, 'n_words': 114, 'path': 'parallel.ipynb', 'repo_name': 'CeSul/notebook-playground', 'size': '1896'}