Skip to content

Commit 206b249

Browse files
committed
fix array_ufunc bug
1 parent 016e057 commit 206b249

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

pandas/_libs/ops_dispatch.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ UFUNC_ALIASES = {
3434
"true_divide": "truediv",
3535
"power": "pow",
3636
"remainder": "mod",
37-
"divide": "div",
37+
"divide": "truediv",
3838
"equal": "eq",
3939
"not_equal": "ne",
4040
"less": "lt",

pandas/tests/arithmetic/test_numeric.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,7 @@ def test_div_td64arr(self, left, box_cls):
169169
result = right // left
170170
tm.assert_equal(result, expected)
171171

172-
msg = "|".join(
173-
[
174-
"Cannot divide",
175-
# 2021-12-09 new message in npdev
176-
"ufunc 'divide' cannot use operands with types "
177-
r"dtype\('.*'\) and dtype\('<m8\[ns\]'\)",
178-
]
179-
)
172+
msg = "Cannot divide"
180173
with pytest.raises(TypeError, match=msg):
181174
left / right
182175

@@ -253,14 +246,7 @@ def test_numeric_arr_rdiv_tdscalar(self, three_days, numeric_idx, box_with_array
253246
result = three_days / index
254247
tm.assert_equal(result, expected)
255248

256-
msg = "|".join(
257-
[
258-
"cannot use operands with types dtype",
259-
# 2021-12-09 new message in npdev
260-
"ufunc 'divide' cannot use operands with types "
261-
r"dtype\('.*'\) and dtype\('<m8\[ns\]'\)",
262-
]
263-
)
249+
msg = "cannot use operands with types dtype"
264250
with pytest.raises(TypeError, match=msg):
265251
index / three_days
266252

pandas/tests/arithmetic/test_timedelta64.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,13 +1472,7 @@ def test_td64arr_mul_int(self, box_with_array):
14721472
def test_td64arr_mul_tdlike_scalar_raises(self, two_hours, box_with_array):
14731473
rng = timedelta_range("1 days", "10 days", name="foo")
14741474
rng = tm.box_expected(rng, box_with_array)
1475-
msg = "|".join(
1476-
[
1477-
"argument must be an integer",
1478-
"cannot use operands with types dtype",
1479-
r"unsupported operand type\(s\) for \*",
1480-
]
1481-
)
1475+
msg = "argument must be an integer|cannot use operands with types dtype"
14821476
with pytest.raises(TypeError, match=msg):
14831477
rng * two_hours
14841478

@@ -1984,16 +1978,7 @@ def test_td64arr_div_numeric_scalar(self, box_with_array, two):
19841978
result = tdser / two
19851979
tm.assert_equal(result, expected)
19861980

1987-
msg = "|".join(
1988-
[
1989-
"Cannot divide",
1990-
# 2021-12-09 npdev started giving a new message; not sure if it
1991-
# will be changed back
1992-
"ufunc 'divide' cannot use operands with types "
1993-
r"dtype\('.*'\) and dtype\('<m8\[ns\]'\)",
1994-
]
1995-
)
1996-
with pytest.raises(TypeError, match=msg):
1981+
with pytest.raises(TypeError, match="Cannot divide"):
19971982
two / tdser
19981983

19991984
@pytest.mark.parametrize("two", [2, 2.0, np.array(2), np.array(2.0)])
@@ -2070,9 +2055,6 @@ def test_td64arr_div_numeric_array(
20702055
"cannot perform __truediv__",
20712056
"unsupported operand",
20722057
"Cannot divide",
2073-
# 2021-12-09 new message on npdev
2074-
"ufunc 'divide' cannot use operands with types "
2075-
r"dtype\('.*'\) and dtype\('<m8\[ns\]'\)",
20762058
]
20772059
)
20782060
with pytest.raises(TypeError, match=pattern):

0 commit comments

Comments
 (0)