-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REGR: Series.__mod__ behaves different with numexpr #36552
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
Changes from all commits
41bb091
14e8b92
1e2a086
4527d23
ccc7eb6
85db057
ff9e85b
b904d44
4f9b91d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,8 +171,6 @@ def _create_methods(cls, arith_method, comp_method, bool_method, special): | |
mul=arith_method(cls, operator.mul, special), | ||
truediv=arith_method(cls, operator.truediv, special), | ||
floordiv=arith_method(cls, operator.floordiv, special), | ||
# Causes a floating point exception in the tests when numexpr enabled, | ||
# so for now no speedup | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This message should have been moved in #19649 I think Ok if we have not had reports of floating point exceptions since enabled. |
||
mod=arith_method(cls, operator.mod, special), | ||
pow=arith_method(cls, operator.pow, special), | ||
# not entirely sure why this is necessary, but previously was included | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import pytest | ||
|
||
import pandas._testing as tm | ||
from pandas.core.api import DataFrame | ||
from pandas.core.api import DataFrame, Index, Series | ||
from pandas.core.computation import expressions as expr | ||
|
||
_frame = DataFrame(randn(10000, 4), columns=list("ABCD"), dtype="float64") | ||
|
@@ -380,3 +380,41 @@ def test_frame_series_axis(self, axis, arith): | |
|
||
result = op_func(other, axis=axis) | ||
tm.assert_frame_equal(expected, result) | ||
|
||
@pytest.mark.parametrize( | ||
"op", | ||
[ | ||
"__mod__", | ||
pytest.param("__rmod__", marks=pytest.mark.xfail(reason="GH-36552")), | ||
"__floordiv__", | ||
"__rfloordiv__", | ||
], | ||
) | ||
@pytest.mark.parametrize("box", [DataFrame, Series, Index]) | ||
@pytest.mark.parametrize("scalar", [-5, 5]) | ||
def test_python_semantics_with_numexpr_installed(self, op, box, scalar): | ||
# https://github.com/pandas-dev/pandas/issues/36047 | ||
expr._MIN_ELEMENTS = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see it is done like that in other tests as well (so doesn't need to be fixed here), but that doesn't seem a very clean way to patch this, as it will influence other tests as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an class with a teardown_method that resets _MIN_ELEMENTS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but yes we should replace with a fixture. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, didn't see the teardown/setup, only the import at the top .. |
||
data = np.arange(-50, 50) | ||
obj = box(data) | ||
method = getattr(obj, op) | ||
result = method(scalar) | ||
|
||
# compare result with numpy | ||
expr.set_use_numexpr(False) | ||
expected = method(scalar) | ||
expr.set_use_numexpr(True) | ||
tm.assert_equal(result, expected) | ||
|
||
# compare result element-wise with Python | ||
for i, elem in enumerate(data): | ||
if box == DataFrame: | ||
scalar_result = result.iloc[i, 0] | ||
else: | ||
scalar_result = result[i] | ||
try: | ||
expected = getattr(int(elem), op)(scalar) | ||
except ZeroDivisionError: | ||
pass | ||
else: | ||
assert scalar_result == expected |
Uh oh!
There was an error while loading. Please reload this page.