<commit_before>import main as m
from sympy.utilities.lambdify import lambdify

import json
import argparse
import ast

parser = argparse.ArgumentParser()
parser.add_argument('operation')
parser.add_argument('func')
parser.add_argument('options')
args   = parser.parse_args()
operation = args.operation
func      = args.func

options   = json.JSONDecoder().decode(args.options)

# def f(func):
#     def inner(x):
#         return eval(func)
#     return inner

# func = f(func)

if operation == 'minimize':
    results = m.minimize_scalar(lambdify('x', func), options)

print json.JSONEncoder().encode(results)<commit_msg>Generalize exec to work for nnlg and min<commit_after>import main as m
from sympy.utilities.lambdify import lambdify

import json
import argparse
import ast

parser = argparse.ArgumentParser()
parser.add_argument('operation')
parser.add_argument('a')
parser.add_argument('b')
args   = parser.parse_args()
operation = args.operation

if operation == 'minimize':
    func      = args.a
    options   = json.JSONDecoder().decode(args.b)
    results   = m.minimize_scalar(lambdify('x', func), options)
elif operation == 'nnls':
    A = json.JSONDecoder().decode(args.a)
    b = json.JSONDecoder().decode(args.b)
    results = m.nnls(A, b)
    
print json.JSONEncoder().encode(results)
{'fraction_non_alphanumeric': 0.1259600614439324, 'fraction_numerical': 0.0, 'mean_word_length': 4.474789915966387, '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': '1027221', 'n_tokens_mistral': 424, 'n_tokens_neox': 417, 'n_words': 98}