<commit_before>"""
Collect all the data from the npz files generated using npss_kreuz_mc.py and
plot the data in many wonderful ways (or just as a scatter plot).
"""

import sys
import os
import glob
import numpy as np
import matplotlib.pyplot as plt

directory = "."
if len(sys.argv) > 1:
    directory = sys.argv[1]
npzglob = os.path.join(directory, "*.npz")
npzfiles = glob.glob(npzglob)

nfiles = len(npzfiles)
npss = []
kreuz = []
sync = []
sigma = []
N_in = []
r_in = []
w_in = []
for idx, npz in enumerate(npzfiles):
    npzdata = np.load(npz)
    N_in.extend(npzdata["N_in"])
    r_in.extend(npzdata["r_in"])
    w_in.extend(npzdata["w_in"])
    npss.extend(npzdata["npss"])
    kreuz.extend(npzdata["kreuz"])
    sync.extend(npzdata["S_in"])
    if "sigma_in" in npzdata.files:
        sigma.extend(npzdata["sigma_in"])
    else:
        ndata = len(npzdata["npss"])
        sigma.extend([0]*ndata)

# TODO: Filter results where sync == 0, since they had no spiking

npss = np.array(npss)
kreuz = np.array(kreuz)
npss_kr = np.sqrt(1-kreuz/0.3) #-0.0148
errors = npss-npss_kr
relerr = np.zeros(len(npss))
for idx in range(len(npss)):
    if npss[idx]:
        relerr[idx] = abs(npss[idx]-npss_kr[idx])/npss[idx]
    else:
        relerr[idx] = npss_kr[idx]
plt.scatter(npss, npss_kr)
plt.plot([0, 1], [0, 1], "k--")
#for n, e in zip(npss, errors):
#    plt.plot([n, n], [n, n-e], "b-")
plt.xlabel("NPSS")
plt.ylabel("Spike distance (rescaled)")
plt.show()<commit_msg>Colour dots with sigma value<commit_after>"""
Collect all the data from the npz files generated using npss_kreuz_mc.py and
plot the data in many wonderful ways (or just as a scatter plot).
"""

import sys
import os
import glob
import numpy as np
import matplotlib.pyplot as plt

directory = "."
if len(sys.argv) > 1:
    directory = sys.argv[1]
npzglob = os.path.join(directory, "*.npz")
npzfiles = glob.glob(npzglob)

nfiles = len(npzfiles)
npss = []
kreuz = []
sync = []
sigma = []
N_in = []
r_in = []
w_in = []
for idx, npz in enumerate(npzfiles):
    npzdata = np.load(npz)
    N_in.extend(npzdata["N_in"])
    r_in.extend(npzdata["r_in"])
    w_in.extend(npzdata["w_in"])
    npss.extend(npzdata["npss"])
    kreuz.extend(npzdata["kreuz"])
    sync.extend(npzdata["S_in"])
    if "sigma_in" in npzdata.files:
        sigma.extend(npzdata["sigma_in"])
    else:
        ndata = len(npzdata["npss"])
        sigma.extend([0]*ndata)

# TODO: Filter results where sync == 0, since they had no spiking

npss = np.array(npss)
kreuz = np.array(kreuz)
npss_kr = np.sqrt(1-kreuz/0.3) #-0.0148
errors = npss-npss_kr
relerr = np.zeros(len(npss))
for idx in range(len(npss)):
    if npss[idx]:
        relerr[idx] = abs(npss[idx]-npss_kr[idx])/npss[idx]
    else:
        relerr[idx] = npss_kr[idx]
plt.scatter(npss, npss_kr, c=sigma)
plt.plot([0, 1], [0, 1], "k--")
#for n, e in zip(npss, errors):
#    plt.plot([n, n], [n, n-e], "b-")
plt.xlabel("NPSS")
plt.ylabel("Spike distance (rescaled)")
plt.show()
{'fraction_non_alphanumeric': 0.1714862138533961, 'fraction_numerical': 0.010759919300605245, 'mean_word_length': 3.7676282051282053, 'pattern_counts': {'":': 0, '<': 3, '<?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}}
{'dir': 'git-commits-cleaned', 'id': '4605197', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1275, 'n_words': 280}