def test_interpreter_constraints(push_config: PushConfig, instr_set: InstructionSet): name = "infinite_growth" sig = ProgramSignature(arity=0, output_stacks=["int"], push_config=push_config) interpreter = PushInterpreter(instr_set) cb = load_code(name, interpreter) program = Program(code=cb, signature=sig) output = interpreter.run(program, [0], print_trace=True) assert output[0] == int(push_config.numeric_magnitude_limit) assert interpreter.status == PushInterpreterStatus.step_limit_exceeded
def get_program(name: str, sig: ProgramSignature, interpreter: PushInterpreter): cb = load_code(name, interpreter) return Program(code=cb, signature=sig)
def simple_program(simple_genome, simple_program_signature): return Program(code=genome_to_code(simple_genome), signature=simple_program_signature)
def _errors_of_genome(self, genome: Genome) -> np.ndarray: cb = genome_to_code(genome) program = Program(code=cb, signature=self.program_signature) return self.evaluator.evaluate(program)
def program(self) -> Program: """Push program associated with this Individual. Taken from Plush genome.""" if self._program is None: cb = genome_to_code(self.genome) self._program = Program(code=cb, signature=self.signature) return self._program