-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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: pandas testsuite on 2.2.x with numpy 2 fails on numexpr #58548
Comments
Same for the development version:
|
Still an issue with pandas-3.0.0.dev0+991.ga3e751c6b4. The reason is the explicit type repr for all scalar types in numpy 2: s = '(df) / (np.float64(3.0))', types = {}, context = {'optimization': 'aggressive', 'truediv': False}, sanitize = True
def stringToExpression(s, types, context, sanitize: bool=True):
"""Given a string, convert it to a tree of ExpressionNode's.
"""
# sanitize the string for obvious attack vectors that NumExpr cannot
# parse into its homebrew AST. This is to protect the call to `eval` below.
# We forbid `;`, `:`. `[` and `__`, and attribute access via '.'.
# We cannot ban `.real` or `.imag` however...
# We also cannot ban `.\d*j`, where `\d*` is some digits (or none), e.g. 1.5j, 1.j
if sanitize:
no_whitespace = re.sub(r'\s+', '', s)
skip_quotes = re.sub(r'(\'[^\']*\')', '', no_whitespace)
if _blacklist_re.search(skip_quotes) is not None:
> raise ValueError(f'Expression {s} has forbidden control characters.')
E ValueError: Expression (df) / (np.float64(3.0)) has forbidden control characters.
context = {'optimization': 'aggressive', 'truediv': False}
no_whitespace = '(df)/(np.float64(3.0))'
s = '(df) / (np.float64(3.0))'
sanitize = True
skip_quotes = '(df)/(np.float64(3.0))'
types = {}
pandas_numexpr_numpy2/lib64/python3.11/site-packages/numexpr/necompiler.py:283: ValueError |
|
No longer an issue with pandas-3.0.0.dev0+1178.g236d89b856 Now how to find the correct change to backport to 2.x ... |
I don't know this code at all, but I think #59144 was the relevant change? Can we try backporting that? |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I'm currently testing numpy 2 on the the openSUSE python ecosystem. I notice the pandas test suite failing when numpy 2.0.0rc1 is installed instead of 1.26.4.
See also pydata/numexpr#483
Expected Behavior
Passing test suite, proper string evaluation
Installed Versions
The text was updated successfully, but these errors were encountered: