<commit_before>from math import *
del pi
from calc.constants import *
from functools import reduce

# Functions missing from math.
# Negative One To The n, where n is an integer.
def nott(n):
    return 1 - 2*(n & 1)
# Divide a by b, ignoring any divides by zero.
def div_ignore(a, b):
    import warnings
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        return a/b
# Factor n.
def factor(n):
    l = []
    while n != 1:
        for i in range(2, n+1):
            if n%i == 0:
                n //= i
                l.append(i)
                break
    return l

# Formatting shortcuts.
def hex(n):
    print('{:x}'.format(n))
def bin(n):
    print('{:b}'.format(n))
# Evaluate, and print. I just can't think of a way to do this without an 
# eval(). Besides just feeling dirty, it also means syntax errors that can 
# only be caught at runtime, so keep the expression in the input string as 
# simple as possible and watch out for side effects. Example:
# x = big_calculation()
# eprint('x')
def eprint(s):
    # dirtiness
    import inspect
    stack = inspect.stack()
    g = stack[1][0].f_globals
    l = stack[1][0].f_locals
    res = str(eval(s, g, l))
    # dirtiness is done, string representation of s is in res.

    # If there are newlines in the string representation of s, it's probably a 
    # good idea to separate the 's = ' from the rest, since the code that 
    # generated the string representation is expecting indentation to be 
    # constant for all lines.
    if '\n' in res:
        res = '\n' + res
<commit_msg>Didn't realise hex and bin already existed.<commit_after>from math import *
del pi
from calc.constants import *
from functools import reduce

# Functions missing from math.
# Negative One To The n, where n is an integer.
def nott(n):
    return 1 - 2*(n & 1)
# Divide a by b, ignoring any divides by zero.
def div_ignore(a, b):
    import warnings
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        return a/b
# Factor n.
def factor(n):
    l = []
    while n != 1:
        for i in range(2, n+1):
            if n%i == 0:
                n //= i
                l.append(i)
                break
    return l

# Evaluate, and print. I just can't think of a way to do this without an 
# eval(). Besides just feeling dirty, it also means syntax errors that can 
# only be caught at runtime, so keep the expression in the input string as 
# simple as possible and watch out for side effects. Example:
# x = big_calculation()
# eprint('x')
def eprint(s):
    # dirtiness
    import inspect
    stack = inspect.stack()
    g = stack[1][0].f_globals
    l = stack[1][0].f_locals
    res = str(eval(s, g, l))
    # dirtiness is done, string representation of s is in res.

    # If there are newlines in the string representation of s, it's probably a 
    # good idea to separate the 's = ' from the rest, since the code that 
    # generated the string representation is expecting indentation to be 
    # constant for all lines.
    if '\n' in res:
        res = '\n' + res

{'fraction_non_alphanumeric': 0.0973393900064893, 'fraction_numerical': 0.007138221933809215, 'mean_word_length': 2.49546485260771, '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': '59982', 'n_tokens_mistral': 968, 'n_tokens_neox': 930, 'n_words': 410}