Depth of the expression tree Returns ------- depth: int
(self, cache=None)
| 195 | ) |
| 196 | |
| 197 | def _depth(self, cache=None): |
| 198 | """Depth of the expression tree |
| 199 | |
| 200 | Returns |
| 201 | ------- |
| 202 | depth: int |
| 203 | """ |
| 204 | if cache is None: |
| 205 | cache = {} |
| 206 | if not self.dependencies(): |
| 207 | return 1 |
| 208 | else: |
| 209 | result = [] |
| 210 | for expr in self.dependencies(): |
| 211 | if expr._name in cache: |
| 212 | result.append(cache[expr._name]) |
| 213 | else: |
| 214 | result.append(expr._depth(cache) + 1) |
| 215 | cache[expr._name] = result[-1] |
| 216 | return max(result) |
| 217 | |
| 218 | def __setattr__(self, name: str, value: Any) -> None: |
| 219 | if name in ["operands", "_determ_token"]: |