def error_function(program): errors = [] for case in cases: interpreter = PushInterpreter() output = interpreter.run(program, [case], ['_vector_boolean'])[0] if output is None: errors.append(1e5) else: target = binary_decrement(case) errors.append(levenshtein_distance(output, target)) return errors
def error_function(program, debug=False): errors = [] for case in cases: interpreter = PushInterpreter() output = interpreter.run(program, [case], ['_vector_boolean'], debug)[0] target = invert_bitstring(case) if output is None: errors.append(1e5) if not len(output) == len(target): errors.append(1e4) else: errors.append(levenshtein_distance(output, target)) return errors
def test_levenshtein_distance_empty(self): sed = u.levenshtein_distance('Hello', '') self.assertEqual(sed, 5)
def test_levenshtein_distance_std(self): sed = u.levenshtein_distance('Hello', 'World') self.assertEqual(sed, 4)