<commit_before>import pickle
import sys




def main():
    data = pickle.load(file(sys.argv[1]))


if __name__ == "__main__":
    main()<commit_msg>test plotting started.<commit_after>import pickle
import sys
import pylab as plt
from scipy import stats
import numpy as np
import triangle
from matplotlib.backends.backend_pdf import PdfPages


def lookatresults(data):
    plots, thetas = [], []
    P = data[-1][0].T
    for i in xrange(len(P[0])):
        x = [x[i] for x in P]
        theta = r'$\theta_{3:}$ {1:.2f} +{2:.2f}/-{0:.2f}'.format(
            stats.mstats.mode(x)[0][0]-stats.scoreatpercentile(x, 16),
            stats.mstats.mode(x)[0][0],
            stats.scoreatpercentile(x, 84)-stats.mstats.mode(x)[0][0], i+1)
        thetas.append(r'$\theta_{}$'.format(i+1))
        f = plt.figure()
        plt.subplot(111)
        plt.title(theta)
        ker = stats.gaussian_kde(x)
        plt.hist(x, normed=True, alpha=0.2)
        X = np.linspace(0.0, max(x) + .1*max(x), 1000)
        plt.plot(X,ker(X))
        plt.xlabel(r"$\theta_{}$".format(i+1))
        #plt.savefig('theta_{}.png'.format(i))
        plots.append(f)



    plt.figure()
    f = triangle.corner(P, labels=thetas)
    #plt.savefig('trianle.png'.format(i))
    plots.append(f)

    return plots


def main():
    data = pickle.load(file(sys.argv[1]))
    results = lookatresults(data)

    report_plot = PdfPages(sys.argv[1].replace('.pkl', '_testplots.pdf'))

    for f in results:
        report_plot.savefig(f)

    report_plot.close()

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.17530390275111965, 'fraction_numerical': 0.02431222008957134, 'mean_word_length': 2.796116504854369, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '4843049', 'n_tokens_mistral': 623, 'n_tokens_neox': 589, 'n_words': 107}