Esempio n. 1
0
 def reduce(self, code, budget=0):
     assert isinstance(budget, int), budget
     assert budget >= 0, budget
     request = Request()
     request.reduce.code = polish_print(code)
     request.reduce.budget = budget
     reply = self._call(request)
     if not reply.reduce.code:
         raise ValueError('Invalid code: {}'.format(code))
     return {
         'code': polish_parse(str(reply.reduce.code)),
         'budget': int(reply.reduce.budget),
     }
Esempio n. 2
0
def test_polish_serialize_parse(tp, code, value):
    string = polish_print(code)
    assert isinstance(string, str)
    actual_code = polish_parse(string)
    assert actual_code == code
Esempio n. 3
0
def test_reduce_engine_polish_equations(code, expected_code, message):
    string = polish_print(code)
    with skip_if_not_implemented():
        actual_string = main.reduce(string, engine='engine')
    expected_string = polish_print(expected_code)
    assert actual_string == expected_string, message
Esempio n. 4
0
def test_polish_simplify(sexpr, expected):
    polish = polish_print(sexpr_parse(sexpr))
    assert polish_simplify(polish) is sexpr_parse(expected)
Esempio n. 5
0
def test_polish_print_parse(code):
    string = polish_print(code)
    assert isinstance(string, str)
    actual_code = polish_parse(string)
    assert actual_code == code
Esempio n. 6
0
def test_polish_print(example):
    actual = polish_print(example['code'])
    assert actual == example['polish']