Depth of the expression tree Returns ------- depth: int
(self, cache=None)
| 185 | ) |
| 186 | |
| 187 | def _depth(self, cache=None): |
| 188 | """Depth of the expression tree |
| 189 | |
| 190 | Returns |
| 191 | ------- |
| 192 | depth: int |
| 193 | """ |
| 194 | if cache is None: |
| 195 | cache = {} |
| 196 | if not self.dependencies(): |
| 197 | return 1 |
| 198 | else: |
| 199 | result = [] |
| 200 | for expr in self.dependencies(): |
| 201 | if expr._name in cache: |
| 202 | result.append(cache[expr._name]) |
| 203 | else: |
| 204 | result.append(expr._depth(cache) + 1) |
| 205 | cache[expr._name] = result[-1] |
| 206 | return max(result) |
| 207 | |
| 208 | def __setattr__(self, name: str, value: Any) -> None: |
| 209 | if name in ["operands", "_determ_token"]: |