<commit_before>"""General functions and classes to support PsychoPy experiments."""
from __future__ import division

import os
import sys
import time
import json
import argparse
import subprocess
from glob import glob
from string import letters
from math import floor
from subprocess import call
import numpy as np
import pandas as pd
from numpy.random import RandomState
from psychopy import core, event, visual
import psychopy.monitors.calibTools as calib
from psychopy import logging


class Params(object):
    """Stores all of the parameters needed during the experiment.

    Some parameters are set upon initialization from the file 'params.py',
    others can be set from the command line.

    """
    def __init__(self, exp_name, p_file='params'):
        """Initializer for the params object.

        Parameters
        ----------
        exp_name: string, name of the dict we want from the param file

        p_file: string, the name of a parameter file

        """
        self.exp_name = exp_name
        im = __import__(p_file)
        self.param_module = im
        param_dict = getattr(im, exp_name)
        for key, val in param_dict.iteritems():
            setattr(self, key, val)

        self.time = time.asctime()
        self.git_hash = git_hash()

    def set_by_cmdline(self, arglist):
        """Get runtime parameters off the commandline."""
        # Create the parser, set default args
        parser = argparse.ArgumentParser()
        parser.add_argument("-subject", default="test")
        parser.add_argument("-cbid")<commit_msg>Add a __repr__ method to the Params object<commit_after>"""General functions and classes to support PsychoPy experiments."""
from __future__ import division

import os
import sys
import time
import json
import argparse
import subprocess
from glob import glob
from string import letters
from math import floor
from subprocess import call
from pprint import pformat
import numpy as np
import pandas as pd
from numpy.random import RandomState
from psychopy import core, event, visual
import psychopy.monitors.calibTools as calib
from psychopy import logging


class Params(object):
    """Stores all of the parameters needed during the experiment.

    Some parameters are set upon initialization from the file 'params.py',
    others can be set from the command line.

    """
    def __init__(self, exp_name, p_file='params'):
        """Initializer for the params object.

        Parameters
        ----------
        exp_name: string, name of the dict we want from the param file

        p_file: string, the name of a parameter file

        """
        self.exp_name = exp_name
        im = __import__(p_file)
        self.param_module = im
        param_dict = getattr(im, exp_name)
        for key, val in param_dict.iteritems():
            setattr(self, key, val)

        self.time = time.asctime()
        self.git_hash = git_hash()

    def __repr__(self):

        return pformat(self.__dict__)

    def set_by_cmdline(self, arglist):
        """Get runtime parameters off the commandline."""
        # Create the parser, set default args
        parser = argparse.ArgumentParser()
        parser.add_argument("-subject", default="test")
        parser.add_argument("-cbid")
{'fraction_non_alphanumeric': 0.07626076260762607, 'fraction_numerical': 0.0, 'mean_word_length': 2.9526123936816524, 'pattern_counts': {'":': 0, '<': 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': '52153', 'n_tokens_mistral': 868, 'n_tokens_neox': 849, 'n_words': 346}