<commit_before>#!/usr/bin/env python3

import os, sys
sys.path.append(os.path.dirname(__file__))

import matplotlib.pyplot as pp
import numpy as np
import random, support

support.figure()
app_count = support.count_apps()
user_count = support.count_users()
while True:
    while True:
        app = None
        user = random.randrange(user_count)
        data = support.select_data(app=app, user=user)[:, 0]
        length = len(data)
        if length >= 10: break
    pp.clf()
    pp.subplot(2, 1, 1)
    data = 1e-6 * data
    zeros, ones = np.zeros([length, 1]), np.ones([length, 1])
    y = np.array(list(zip(zeros, ones, zeros))).flatten()
    x = np.array(list(zip(data, data, data))).flatten()
    pp.plot(x, y)
    pp.xlabel('Time')
    pp.xlim([x[0], x[-1]])
    pp.title('Arrivals (app {}, user {}, {} samples)'.format(app, user, length))
    pp.subplot(2, 1, 2)
    y = np.diff(data)
    x = np.arange(0, len(y))
    pp.plot(x, y)
    pp.xlim([x[0], x[-1]])
    pp.ylim([0, max(y)])
    pp.title('Interarrivals')
    pp.ylabel('Time')
    pp.gcf().subplots_adjust(hspace=0.5)
    pp.pause(1)
    input()<commit_msg>Let the explore script take an argument<commit_after>#!/usr/bin/env python3

import os, sys
sys.path.append(os.path.dirname(__file__))

import matplotlib.pyplot as pp
import numpy as np
import random, support

def display(data, app, user):
    pp.clf()
    pp.subplot(2, 1, 1)
    length = len(data)
    zeros, ones = np.zeros([length, 1]), np.ones([length, 1])
    y = np.array(list(zip(zeros, ones, zeros))).flatten()
    x = np.array(list(zip(data, data, data))).flatten()
    pp.plot(x, y)
    pp.xlabel('Time')
    pp.xlim([x[0], x[-1]])
    pp.title('Arrivals (app {}, user {}, {} samples)'.format(app, user, length))
    pp.subplot(2, 1, 2)
    y = np.diff(data)
    x = np.arange(0, len(y))
    pp.plot(x, y)
    pp.xlim([x[0], x[-1]])
    pp.ylim([0, max(y)])
    pp.title('Interarrivals')
    pp.ylabel('Time')
    pp.gcf().subplots_adjust(hspace=0.5)
    pp.pause(1e-3)

support.figure()

if len(sys.argv) > 1:
    app = None
    user = int(sys.argv[1])
    data = 1e-6 * support.select_data(app=app, user=user)[:, 0]
    display(data, app=app, user=user)
    input()
else:
    app_count = support.count_apps()
    user_count = support.count_users()
    while True:
        while True:
            app = None
            user = random.randrange(user_count)
            data = support.select_data(app=app, user=user)[:, 0]
            if len(data) >= 10: break
        display(1e-6 * data, app=app, user=user)
        if input('More? ') == 'no': break
{'fraction_non_alphanumeric': 0.18192352259559674, 'fraction_numerical': 0.020084974893781384, 'mean_word_length': 2.930197268588771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '2303099', 'n_tokens_mistral': 1025, 'n_tokens_neox': 999, 'n_words': 212}