Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: pandas nightly
  • Loading branch information
cmp0xff committed Aug 4, 2025
commit 0d9931a47ad06f6c7d4190307c6cf804e86d7a7c
37 changes: 24 additions & 13 deletions tests/series/arithmetic/test_truediv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from tests import (
PD_LTE_23,
WINDOWS,
check,
)

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


def test_path_div() -> None:
# GH 682
folder = Path.cwd()
def test_path_div(tmp_path: Path) -> None:
"""Test pd.Series of paths / path object.

folders = pd.Series([folder, folder])
check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path)
Also GH 682."""
fpath = Path("a.png")
folders, fpaths = pd.Series([tmp_path, tmp_path]), pd.Series([fpath, fpath])

check(assert_type(folders / fpath, pd.Series), pd.Series, Path)
check(assert_type(folders.truediv(fpath), pd.Series), pd.Series, Path)
check(assert_type(folders.div(fpath), pd.Series), pd.Series, Path)

check(assert_type(tmp_path / fpaths, pd.Series), pd.Series, Path)
check(assert_type(fpaths.rtruediv(tmp_path), pd.Series), pd.Series, Path)
check(assert_type(fpaths.rdiv(tmp_path), pd.Series), pd.Series, Path)


def test_truediv_path() -> None:
def test_truediv_path(tmp_path: Path) -> None:
"""Test pd.Series / path object.

Also GH 682."""
left, p = pd.Series(["a.png", "b.gz", "c.txt"]), Path.cwd()
fnames = pd.Series(["a.png", "b.gz", "c.txt"])

check(assert_type(left / p, pd.Series), pd.Series, Path)
if PD_LTE_23:
# Bug in 3.0 https://github.com/pandas-dev/pandas/issues/61940
check(assert_type(p / left, pd.Series), pd.Series, Path)
check(assert_type(fnames / tmp_path, pd.Series), pd.Series, Path)
check(assert_type(tmp_path / fnames, pd.Series), pd.Series, Path)

check(assert_type(left.truediv(p), pd.Series), pd.Series, Path)
check(assert_type(left.div(p), pd.Series), pd.Series, Path)
if PD_LTE_23 or not WINDOWS:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The or not WINDOWS should not be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# pyarrow.lib.ArrowInvalid: Could not convert WindowsPath('...') with type WindowsPath: did not recognize Python value type when inferring an Arrow data type
check(assert_type(fnames.truediv(tmp_path), pd.Series), pd.Series, Path)
check(assert_type(fnames.div(tmp_path), pd.Series), pd.Series, Path)

check(assert_type(left.rtruediv(p), pd.Series), pd.Series, Path)
check(assert_type(left.rdiv(p), pd.Series), pd.Series, Path)
check(assert_type(fnames.rtruediv(tmp_path), pd.Series), pd.Series, Path)
check(assert_type(fnames.rdiv(tmp_path), pd.Series), pd.Series, Path)
Loading