Skip to content

Commit

Permalink
FIX: ruff checks in expressions/pytables (#60541)
Browse files Browse the repository at this point in the history
* FIX: ruff checks in expressions/pytables

* swap condition

* more pre-commit
  • Loading branch information
mroeschke authored Dec 11, 2024
1 parent ca91dd4 commit 719fc0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pandas/core/computation/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _evaluate_numexpr(op, op_str, left_op, right_op):
try:
result = ne.evaluate(
f"left_value {op_str} right_value",
local_dict={"left_value": left_value, "right_value": right_op},
local_dict={"left_value": left_value, "right_value": right_value},
casting="safe",
)
except TypeError:
Expand Down Expand Up @@ -257,7 +257,10 @@ def where(cond, left_op, right_op, use_numexpr: bool = True):
Whether to try to use numexpr.
"""
assert _where is not None
return _where(cond, left_op, right_op) if use_numexpr else _where_standard(cond, left_op, right_op)
if use_numexpr:
return _where(cond, left_op, right_op)
else:
return _where_standard(cond, left_op, right_op)


def set_test_mode(v: bool = True) -> None:
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ def stringify(value):
# string quoting
return TermValue(conv_val, stringify(conv_val), "string")
else:
raise TypeError(f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column")
raise TypeError(
f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column"
)

def convert_values(self) -> None:
pass
Expand Down

0 comments on commit 719fc0f

Please sign in to comment.