Skip to content

Commit 8bf1142

Browse files
undid my change in pandas/core/ops/__init__.py and handle the case differently in pandas/tests/base/test_ops.py
1 parent 452335a commit 8bf1142

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pandas/core/ops/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def _get_opstr(op):
265265
rtruediv: "/",
266266
operator.floordiv: "//",
267267
rfloordiv: "//",
268-
operator.mod: "%",
268+
operator.mod: None, # TODO: Why None for mod but '%' for rmod?
269269
rmod: "%",
270270
operator.pow: "**",
271271
rpow: "**",

pandas/tests/base/test_ops.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import datetime, timedelta
22
from io import StringIO
3+
import operator
34
import sys
45
from typing import Any
56

@@ -86,9 +87,13 @@ def setup_method(self, method):
8687

8788
@pytest.mark.parametrize("klass", [Series, DataFrame])
8889
def test_binary_ops_docs(klass, all_arithmetic_functions):
89-
operator = all_arithmetic_functions
90-
operator_name = _get_op_name(operator, special=False)
91-
operator_symbol = _get_opstr(operator)
90+
op = all_arithmetic_functions
91+
operator_name = _get_op_name(op, special=False)
92+
if op is operator.mod:
93+
# _get_opstr returns 'None' for this operator
94+
operator_symbol = "%"
95+
else:
96+
operator_symbol = _get_opstr(op)
9297
is_reverse = operator_name.startswith("r")
9398

9499
operand1 = klass.__name__.lower()

0 commit comments

Comments
 (0)