Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix approach to detecting assignment for gte/lte operators #13285

Merged
merged 3 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7133,12 +7133,12 @@ def eval(self, expr: str, inplace: bool = False, **kwargs):
)

# Have to use a regex match to avoid capturing "=="
includes_assignment = re.search("[^=]=[^=]", expr) is not None
includes_assignment = re.search("[^=><]=[^=><]", expr) is not None
vyasr marked this conversation as resolved.
Show resolved Hide resolved

# Check if there were multiple statements. Filter out empty lines.
statements = tuple(filter(None, expr.strip().split("\n")))
if len(statements) > 1 and any(
re.search("[^=]=[^=]", st) is None for st in statements
re.search("[^=><]=[^=><]", st) is None for st in statements
vyasr marked this conversation as resolved.
Show resolved Hide resolved
):
raise ValueError(
"Multi-line expressions are only valid if all expressions "
Expand Down
3 changes: 2 additions & 1 deletion python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -9794,6 +9794,7 @@ def df_eval(request):
("a / b", float),
("a * b", int),
("a > b", int),
("a >= b", int),
("a > b > c", int),
("a > b < c", int),
("a & b", int),
Expand Down Expand Up @@ -9832,7 +9833,7 @@ def test_dataframe_eval(df_eval, expr, dtype):
assert_eq(expect, got, check_names=False)

# Test inplace
if re.search("[^=]=[^=]", expr) is not None:
if re.search("[^=><]=[^=><]", expr) is not None:
pdf_eval = df_eval.to_pandas()
pdf_eval.eval(expr, inplace=True)
df_eval.eval(expr, inplace=True)
Expand Down