Return the list of variable names in the Numexpr `expression`.
(
expression: ne.expressions.ExpressionNode,
)
| 434 | |
| 435 | |
| 436 | def _get_variable_names( |
| 437 | expression: ne.expressions.ExpressionNode, |
| 438 | ) -> list[str]: |
| 439 | """Return the list of variable names in the Numexpr `expression`.""" |
| 440 | names = [] |
| 441 | stack = [expression] |
| 442 | while stack: |
| 443 | node = stack.pop() |
| 444 | if node.astType == "variable": |
| 445 | names.append(node.value) |
| 446 | elif hasattr(node, "children"): |
| 447 | stack.extend(node.children) |
| 448 | return list(set(names)) # remove repeated names |
| 449 | |
| 450 | |
| 451 | def compile_condition( |
no test coverage detected