-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Multiline Eval broken for local variables after first line #15343
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
BUG: Multiline Eval broken for local variables after first line #15343
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15343 +/- ##
==========================================
- Coverage 86.32% 86.32% -0.01%
==========================================
Files 141 141
Lines 51163 51162 -1
==========================================
- Hits 44167 44166 -1
Misses 6996 6996
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
expected['d'] = expected['c'] + local_var | ||
ans = df.eval(""" | ||
c = a * @local_var | ||
d = c + @local_var |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test with a blank lines as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does actually have a blank line. The """, inplace=...
that terminates the string causes a line of nothing but space at the end of the string. Formulating the test case this way was how I found that the .strip()
was needed in the compare.
@@ -1411,6 +1411,22 @@ def test_multi_line_expression_not_inplace(self): | |||
e = a + 2""", inplace=False) | |||
assert_frame_equal(expected, df) | |||
|
|||
def test_multi_line_expression_local_variable(self): | |||
# GH 15342 | |||
tm.skip_if_no_ne('numexpr') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't need the skip (this is done generically)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a cut and paste from the test case above. I assumed it was desired boilerplate. It is present in the three test cases above the the test case I added. Would you like me to take some action on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you should be able to remove from the tests above too.
Thanks @stephenrauch - I only half remember how the scope level works - is there any way to make this clearer / cleaner? We're now doing a |
@chris-b1 , so yesterday was the first time I had seen this code base, so I am not familiar with the workings of the scope levels. I did see all of the +1's, and thought it note-worthy, but didn't investigate any further. |
Looked at this again, and I'm fine with your fix. |
…line Also fixes the code which attempted to ignore any blank lines in the multiline expression. Also removes some extra `tm.skip_if_no_ne('numexpr')`.
c7ac553
to
fe67ede
Compare
thanks @stephenrauch ! |
Also fixes the code which attempted to ignore any blank lines in the multiline expression. closes pandas-dev#15342 Author: Stephen Rauch <[email protected]> Closes pandas-dev#15343 from stephenrauch/multi-line-eval-with-local and squashes the following commits: fe67ede [Stephen Rauch] BUG: GH15342 - Multiline Eval broken for local variables after first line
Also fixes the code which attempted to ignore any blank lines in the
multiline expression.
git diff upstream/master | flake8 --diff