Skip to content

Commit 0d9931a

Browse files
committed
fix: pandas nightly
1 parent 935b475 commit 0d9931a

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

tests/series/arithmetic/test_truediv.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from tests import (
99
PD_LTE_23,
10+
WINDOWS,
1011
check,
1112
)
1213

@@ -143,27 +144,37 @@ def test_truediv_pd_series() -> None:
143144
check(assert_type(left.rdiv(c), pd.Series), pd.Series)
144145

145146

146-
def test_path_div() -> None:
147-
# GH 682
148-
folder = Path.cwd()
147+
def test_path_div(tmp_path: Path) -> None:
148+
"""Test pd.Series of paths / path object.
149149
150-
folders = pd.Series([folder, folder])
151-
check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path)
150+
Also GH 682."""
151+
fpath = Path("a.png")
152+
folders, fpaths = pd.Series([tmp_path, tmp_path]), pd.Series([fpath, fpath])
153+
154+
check(assert_type(folders / fpath, pd.Series), pd.Series, Path)
155+
check(assert_type(folders.truediv(fpath), pd.Series), pd.Series, Path)
156+
check(assert_type(folders.div(fpath), pd.Series), pd.Series, Path)
157+
158+
check(assert_type(tmp_path / fpaths, pd.Series), pd.Series, Path)
159+
check(assert_type(fpaths.rtruediv(tmp_path), pd.Series), pd.Series, Path)
160+
check(assert_type(fpaths.rdiv(tmp_path), pd.Series), pd.Series, Path)
152161

153162

154-
def test_truediv_path() -> None:
163+
def test_truediv_path(tmp_path: Path) -> None:
155164
"""Test pd.Series / path object.
156165
157166
Also GH 682."""
158-
left, p = pd.Series(["a.png", "b.gz", "c.txt"]), Path.cwd()
167+
fnames = pd.Series(["a.png", "b.gz", "c.txt"])
159168

160-
check(assert_type(left / p, pd.Series), pd.Series, Path)
161169
if PD_LTE_23:
162170
# Bug in 3.0 https://github.com/pandas-dev/pandas/issues/61940
163-
check(assert_type(p / left, pd.Series), pd.Series, Path)
171+
check(assert_type(fnames / tmp_path, pd.Series), pd.Series, Path)
172+
check(assert_type(tmp_path / fnames, pd.Series), pd.Series, Path)
164173

165-
check(assert_type(left.truediv(p), pd.Series), pd.Series, Path)
166-
check(assert_type(left.div(p), pd.Series), pd.Series, Path)
174+
if PD_LTE_23 or not WINDOWS:
175+
# pyarrow.lib.ArrowInvalid: Could not convert WindowsPath('...') with type WindowsPath: did not recognize Python value type when inferring an Arrow data type
176+
check(assert_type(fnames.truediv(tmp_path), pd.Series), pd.Series, Path)
177+
check(assert_type(fnames.div(tmp_path), pd.Series), pd.Series, Path)
167178

168-
check(assert_type(left.rtruediv(p), pd.Series), pd.Series, Path)
169-
check(assert_type(left.rdiv(p), pd.Series), pd.Series, Path)
179+
check(assert_type(fnames.rtruediv(tmp_path), pd.Series), pd.Series, Path)
180+
check(assert_type(fnames.rdiv(tmp_path), pd.Series), pd.Series, Path)

0 commit comments

Comments
 (0)