MCPcopy Create free account
hub / github.com/Morgansy/Genetic-Alpha / validate_program

Method validate_program

_program.py:300–311  ·  view source on GitHub ↗

Rough check that the embedded program in the object is valid.

(self)

Source from the content-addressed store, hash-verified

298 return None
299
300 def validate_program(self):
301 """Rough check that the embedded program in the object is valid."""
302 terminals = [0]
303 for node in self.program:
304 if isinstance(node, _Function):
305 terminals.append(node.arity)
306 else:
307 terminals[-1] -= 1
308 while terminals[-1] == 0:
309 terminals.pop()
310 terminals[-1] -= 1
311 return terminals == [-1]
312
313 def __str__(self):
314 """Overloads `print` output of the object to resemble a LISP tree."""

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected