Evaluate a binary operation *before* being passed to the engine. Parameters ---------- env : Scope engine : str parser : str term_type : type eval_in_python : list Returns ------- term_type The "pr
(self, env, engine: str, parser, term_type, eval_in_python)
| 379 | return self.func(left, right) |
| 380 | |
| 381 | def evaluate(self, env, engine: str, parser, term_type, eval_in_python): |
| 382 | """ |
| 383 | Evaluate a binary operation *before* being passed to the engine. |
| 384 | |
| 385 | Parameters |
| 386 | ---------- |
| 387 | env : Scope |
| 388 | engine : str |
| 389 | parser : str |
| 390 | term_type : type |
| 391 | eval_in_python : list |
| 392 | |
| 393 | Returns |
| 394 | ------- |
| 395 | term_type |
| 396 | The "pre-evaluated" expression as an instance of ``term_type`` |
| 397 | """ |
| 398 | if engine == "python": |
| 399 | res = self(env) |
| 400 | else: |
| 401 | # recurse over the left/right nodes |
| 402 | |
| 403 | left = self.lhs.evaluate( |
| 404 | env, |
| 405 | engine=engine, |
| 406 | parser=parser, |
| 407 | term_type=term_type, |
| 408 | eval_in_python=eval_in_python, |
| 409 | ) |
| 410 | |
| 411 | right = self.rhs.evaluate( |
| 412 | env, |
| 413 | engine=engine, |
| 414 | parser=parser, |
| 415 | term_type=term_type, |
| 416 | eval_in_python=eval_in_python, |
| 417 | ) |
| 418 | |
| 419 | # base cases |
| 420 | if self.op in eval_in_python: |
| 421 | res = self.func(left.value, right.value) |
| 422 | else: |
| 423 | from pandas.core.computation.eval import eval |
| 424 | |
| 425 | res = eval(self, local_dict=env, engine=engine, parser=parser) |
| 426 | |
| 427 | name = env.add_tmp(res) |
| 428 | return term_type(name, env=env) |
| 429 | |
| 430 | def convert_values(self) -> None: |
| 431 | """ |