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

Method _depth

_program.py:398–411  ·  view source on GitHub ↗

Calculates the maximum depth of the program tree.

(self)

Source from the content-addressed store, hash-verified

396 return None
397
398 def _depth(self):
399 """Calculates the maximum depth of the program tree."""
400 terminals = [0]
401 depth = 1
402 for node in self.program:
403 if isinstance(node, _Function):
404 terminals.append(node.arity)
405 depth = max(len(terminals), depth)
406 else:
407 terminals[-1] -= 1
408 while terminals[-1] == 0:
409 terminals.pop()
410 terminals[-1] -= 1
411 return depth - 1
412
413 def _length(self):
414 """Calculates the number of functions and terminals in the program."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected