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