Calculates the maximum depth of the program tree.
(self)
| 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.""" |
nothing calls this directly
no outgoing calls
no test coverage detected