<commit_before>from scipy.optimize import minimize
from theano import function, scan
import theano.tensor as T
from numpy import inf, array
from numpy.core.records import recarray
import numpy as np
from math import pi
from collections import OrderedDict as OD
import logging

from .util import hessian_
from .memoize import memoize

__all__ = ['var', 'par', 'Normal', 'Uniform', 'Exponential', 'Power', 'Mix2']

def alltrue(vals):
    ret = 1
    for c in vals:
        ret = ret * (1 * c)
    return ret

def bound(logp, *conditions):
    return T.switch(alltrue(conditions), logp, -inf)

def var(name, label=None):
    return Variable(name, label)

def par(name, label=None, lower=None, upper=None):
    return Parameter(name, label, lower, upper)

class Variable(object):
    def __init__(self, name, label=None):
        self.name = name
        if label:
            self.label = label
        else:
            self.label = name
        self.tvar = T.vector(name)

    def __rmul__(self, other):
        other * self.tvar

    def __mul__(self, other):
        self.tvar * other

    def __rdiv__(self, other):
        other / self.tvar

    def __div__(self, other):
        self.tvar / other

    def __radd__(self, other):
        other + self.tvar

    def __add__(self, other):
        self.tvar + other

    def __rsub__(self, other):
        other - self.tvar

    def __sub__(self, other):
        self.tvar - other


class Parameter(object):
    def __init__(self, name, label=None, lower=None, upper=None):
        self.name = name
        if label:
            self.label = label
        else:
            self.label = name
        self.lower = lower
        self.upper = upper
        self.tvar = T.scalar(name)

    def __rmul__(self, other):
        other * self.tvar

    def __mul__(self, other):
        self.tvar * other

    def __rdiv__(self, other):
        other / self.tvar

    def __div__(self, other):
        self.tvar / other

    def __radd__(self, other):
        other + self.tvar

    def __add__(self, other):
        self.tvar + other

    def __rsub__(self, other):
        other - self.tvar

    def __sub__(self, other):
        self.tvar - other

class Distribution(object):
    def __init__(self):
        self.var = OD()
        self.param = OD()<commit_msg>add string representations for variables and parameters<commit_after>from scipy.optimize import minimize
from theano import function, scan
import theano.tensor as T
from numpy import inf, array
from numpy.core.records import recarray
import numpy as np
from math import pi
from collections import OrderedDict as OD
import logging

from .util import hessian_
from .memoize import memoize

__all__ = ['var', 'par', 'Normal', 'Uniform', 'Exponential', 'Power', 'Mix2']

def alltrue(vals):
    ret = 1
    for c in vals:
        ret = ret * (1 * c)
    return ret

def bound(logp, *conditions):
    return T.switch(alltrue(conditions), logp, -inf)

def var(name, label=None):
    return Variable(name, label)

def par(name, label=None, lower=None, upper=None):
    return Parameter(name, label, lower, upper)

class Variable(object):
    def __init__(self, name, label=None):
        self.name = name
        if label:
            self.label = label
        else:
            self.label = name
        self.tvar = T.vector(name)

    def __repr__(self):
        return self.label

    def __rmul__(self, other):
        other * self.tvar

    def __mul__(self, other):
        self.tvar * other

    def __rdiv__(self, other):
        other / self.tvar

    def __div__(self, other):
        self.tvar / other

    def __radd__(self, other):
        other + self.tvar

    def __add__(self, other):
        self.tvar + other

    def __rsub__(self, other):
        other - self.tvar

    def __sub__(self, other):
        self.tvar - other


class Parameter(object):
    def __init__(self, name, label=None, lower=None, upper=None):
        self.name = name
        if label:
            self.label = label
        else:
            self.label = name
        self.lower = lower
        self.upper = upper
        self.tvar = T.scalar(name)

    def __repr__(self):
        return self.label

    def __rmul__(self, other):
        other * self.tvar

    def __mul__(self, other):
        self.tvar * other

    def __rdiv__(self, other):
        other / self.tvar

    def __div__(self, other):
        self.tvar / other

    def __radd__(self, other):
        other + self.tvar

    def __add__(self, other):
        self.tvar + other

    def __rsub__(self, other):
        other - self.tvar

    def __sub__(self, other):
        self.tvar - other

class Distribution(object):
    def __init__(self):
        self.var = OD()
        self.param = OD()
{'fraction_non_alphanumeric': 0.10307109802271772, 'fraction_numerical': 0.0012620950778291964, 'mean_word_length': 2.281573498964803, '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': '7420522', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1464, 'n_words': 451}