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), }
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
def polish_simplify(string): return polish_parse(string, SIGNATURE)
def test_polish_print_parse(code): string = polish_print(code) assert isinstance(string, str) actual_code = polish_parse(string) assert actual_code == code
def test_polish_parse(example): actual = polish_parse(example['polish']) assert actual == example['code']