Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

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
feat(test): mul
  • Loading branch information
cmp0xff committed Sep 23, 2025
commit 09aeaf73b6e8aaa7fcf5073e606999f77dc93080
8 changes: 0 additions & 8 deletions pandas-stubs/core/arraylike.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class OpsMixin:
def __rxor__(self, other: Any) -> Self: ...
# -------------------------------------------------------------
# Arithmetic Methods
def __mul__(self, other: Any) -> Self: ...
def __rmul__(self, other: Any) -> Self: ...
# Handled by subclasses that specify only the valid values
# that can be passed
# def __truediv__(self, other: Any) -> Self: ...
# def __rtruediv__(self, other: Any) -> Self: ...
# def __floordiv__(self, other: Any) -> Self: ...
# def __rfloordiv__(self, other: Any) -> Self: ...
def __mod__(self, other: Any) -> Self: ...
def __rmod__(self, other: Any) -> Self: ...
def __divmod__(self, other: Any) -> tuple[Self, Self]: ...
Expand Down
2 changes: 2 additions & 0 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1806,6 +1806,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
level: Level | None = ...,
fill_value: float | None = None,
) -> Self: ...
def __mul__(self, other: Any) -> Self: ...
def __rmul__(self, other: Any) -> Self: ...
@final
def add_prefix(self, prefix: _str, axis: Axis | None = None) -> Self: ...
@final
Expand Down
5 changes: 3 additions & 2 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ class Index(IndexOpsMixin[S1]):
@overload
def __sub__(self: Index[Never], other: DatetimeIndex) -> Never: ...
@overload
def __sub__(self: Index[Never], other: complex | NumListLike | Index) -> Index: ...
def __sub__(self: Index[Never], other: complex | _ListLike | Index) -> Index: ...
@overload
def __sub__(self, other: Index[Never]) -> Index: ...
@overload
Expand Down Expand Up @@ -770,7 +770,8 @@ class Index(IndexOpsMixin[S1]):
self: Index[int] | Index[float], other: timedelta
) -> TimedeltaIndex: ...
@overload
def __mul__(self, other: Any) -> Self: ...
def __mul__(self, other: S1 | Sequence[S1] | Index[S1]) -> Self: ...
def __rmul__(self, other: S1 | Sequence[S1] | Index[S1]) -> Self: ...
def __floordiv__(
self,
other: (
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/indexes/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class TimedeltaIndex(
def __sub__( # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
self, other: dt.timedelta | np.timedelta64 | np_ndarray_td | Self
) -> Self: ...
def __mul__(self, other: num) -> Self: ...
def __mul__(self, other: float) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
@overload # type: ignore[override]
def __truediv__(self, other: num | Sequence[float]) -> Self: ...
def __truediv__(self, other: float | Sequence[float]) -> Self: ...
@overload
def __truediv__( # pyright: ignore[reportIncompatibleMethodOverride]
self, other: dt.timedelta | Sequence[dt.timedelta]
Expand Down
8 changes: 6 additions & 2 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
self, other: S1 | _ListLike | Series[S1] | datetime | timedelta | date
) -> Series[_bool]: ...
@overload
def __mul__(
def __mul__( # type: ignore[overload-overlap]
self: Series[Never], other: complex | NumListLike | Series
) -> Series: ...
@overload
Expand Down Expand Up @@ -2532,6 +2532,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
),
) -> Series[Timedelta]: ...
@overload
def __mul__(self: Series[Timedelta], other: np_ndarray_complex) -> Never: ...
@overload
def __mul__(
self: Series[Timedelta],
other: (
Expand Down Expand Up @@ -2704,7 +2706,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
axis: AxisIndex | None = 0,
) -> Series[Timedelta]: ...
@overload
def __rmul__(
def __rmul__( # type: ignore[overload-overlap]
self: Series[Never], other: complex | NumListLike | Series
) -> Series: ...
@overload
Expand Down Expand Up @@ -2778,6 +2780,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
),
) -> Series[Timedelta]: ...
@overload
def __rmul__(self: Series[Timedelta], other: np_ndarray_complex) -> Never: ...
@overload
def __rmul__(
self: Series[Timedelta],
other: (
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/bool/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_add_numpy_array() -> None:


def test_add_pd_index() -> None:
"""Test pd.Index[bool] + pandas index"""
"""Test pd.Index[bool] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/bool/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_sub_numpy_array() -> None:


def test_sub_pd_index() -> None:
"""Test pd.Index[bool] - pandas index"""
"""Test pd.Index[bool] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/complex/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_add_numpy_array() -> None:


def test_add_pd_index() -> None:
"""Test pd.Index[complex] + pandas index"""
"""Test pd.Index[complex] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/complex/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_sub_numpy_array() -> None:


def test_sub_pd_index() -> None:
"""Test pd.Index[complex] - pandas index"""
"""Test pd.Index[complex] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/float/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_add_numpy_array() -> None:


def test_add_pd_index() -> None:
"""Test pd.Index[float] + pandas index"""
"""Test pd.Index[float] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/float/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_sub_numpy_array() -> None:


def test_sub_pd_index() -> None:
"""Test pd.Index[float] - pandas index"""
"""Test pd.Index[float] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/int/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_add_numpy_array() -> None:


def test_add_pd_index() -> None:
"""Test pd.Index[int] + pandas index"""
"""Test pd.Index[int] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/int/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_sub_numpy_array() -> None:


def test_sub_pd_index() -> None:
"""Test pd.Index[int] - pandas index"""
"""Test pd.Index[int] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/str/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_add_numpy_array() -> None:


def test_add_pd_index() -> None:
"""Test pd.Index[str] + pandas index"""
"""Test pd.Index[str] + pandas indexes"""
i = pd.Index([3, 5, 8])
r0 = pd.Index(["a", "bc", "def"])

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_add_i_numpy_array() -> None:


def test_add_i_pd_index() -> None:
"""Test pd.Index[Any] (int) + pandas index"""
"""Test pd.Index[Any] (int) + pandas indexes"""
a = pd.MultiIndex.from_tuples([(1,), (2,), (3,)]).levels[0]
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/arithmetic/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_sub_i_numpy_array() -> None:


def test_sub_i_pd_index() -> None:
"""Test pd.Index[Any] (int) - pandas index"""
"""Test pd.Index[Any] (int) - pandas indexes"""
a = pd.MultiIndex.from_tuples([(1,), (2,), (3,)]).levels[0]
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
Expand Down
24 changes: 12 additions & 12 deletions tests/series/arithmetic/bool/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ def test_add_numpy_array() -> None:
)


def test_add_pd_series() -> None:
"""Test pd.Series[bool] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])
def test_add_pd_index() -> None:
"""Test pd.Series[bool] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[bool]"), pd.Series, np.bool_)
check(assert_type(left + i, "pd.Series[int]"), pd.Series, np.integer)
Expand All @@ -129,12 +129,12 @@ def test_add_pd_series() -> None:
)


def test_add_pd_index() -> None:
"""Test pd.Series[bool] + pandas index"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])
def test_add_pd_series() -> None:
"""Test pd.Series[bool] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[bool]"), pd.Series, np.bool_)
check(assert_type(left + i, "pd.Series[int]"), pd.Series, np.integer)
Expand Down
24 changes: 12 additions & 12 deletions tests/series/arithmetic/bool/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def test_sub_numpy_array() -> None:
)


def test_sub_pd_series() -> None:
"""Test pd.Series[bool] - pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])
def test_sub_pd_index() -> None:
"""Test pd.Series[bool] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])

if TYPE_CHECKING_INVALID_USAGE:
_0 = left - b # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
Expand Down Expand Up @@ -151,12 +151,12 @@ def test_sub_pd_series() -> None:
)


def test_sub_pd_index() -> None:
"""Test pd.Series[bool] - pandas index"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])
def test_sub_pd_series() -> None:
"""Test pd.Series[bool] - pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])

if TYPE_CHECKING_INVALID_USAGE:
_0 = left - b # type: ignore[operator] # pyright: ignore[reportOperatorIssue]
Expand Down
24 changes: 12 additions & 12 deletions tests/series/arithmetic/complex/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ def test_add_numpy_array() -> None:
)


def test_add_pd_series() -> None:
"""Test pd.Series[complex] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])
def test_add_pd_index() -> None:
"""Test pd.Series[complex] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left + i, "pd.Series[complex]"), pd.Series, np.complexfloating)
Expand Down Expand Up @@ -155,12 +155,12 @@ def test_add_pd_series() -> None:
)


def test_add_pd_index() -> None:
"""Test pd.Series[complex] + pandas index"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])
def test_add_pd_series() -> None:
"""Test pd.Series[complex] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left + i, "pd.Series[complex]"), pd.Series, np.complexfloating)
Expand Down
36 changes: 36 additions & 0 deletions tests/series/arithmetic/complex/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,42 @@ def test_sub_numpy_array() -> None:
)


def test_sub_pd_index() -> None:
"""Test pd.Series[complex] - pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])

check(assert_type(left - b, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left - i, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left - f, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left - c, "pd.Series[complex]"), pd.Series, np.complexfloating)

check(assert_type(b - left, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(i - left, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(f - left, "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(c - left, "pd.Series[complex]"), pd.Series, np.complexfloating)

check(assert_type(left.sub(b), "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left.sub(i), "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left.sub(f), "pd.Series[complex]"), pd.Series, np.complexfloating)
check(assert_type(left.sub(c), "pd.Series[complex]"), pd.Series, np.complexfloating)

check(
assert_type(left.rsub(b), "pd.Series[complex]"), pd.Series, np.complexfloating
)
check(
assert_type(left.rsub(i), "pd.Series[complex]"), pd.Series, np.complexfloating
)
check(
assert_type(left.rsub(f), "pd.Series[complex]"), pd.Series, np.complexfloating
)
check(
assert_type(left.rsub(c), "pd.Series[complex]"), pd.Series, np.complexfloating
)


def test_sub_pd_series() -> None:
"""Test pd.Series[complex] - pandas series"""
b = pd.Series([True, False, True])
Expand Down
24 changes: 12 additions & 12 deletions tests/series/arithmetic/float/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ def test_add_numpy_array() -> None:
)


def test_add_pd_series() -> None:
"""Test pd.Series[float] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])
def test_add_pd_index() -> None:
"""Test pd.Series[float] + pandas indexes"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[float]"), pd.Series, np.floating)
check(assert_type(left + i, "pd.Series[float]"), pd.Series, np.floating)
Expand All @@ -129,12 +129,12 @@ def test_add_pd_series() -> None:
)


def test_add_pd_index() -> None:
"""Test pd.Series[float] + pandas index"""
b = pd.Index([True, False, True])
i = pd.Index([2, 3, 5])
f = pd.Index([1.0, 2.0, 3.0])
c = pd.Index([1.1j, 2.2j, 4.1j])
def test_add_pd_series() -> None:
"""Test pd.Series[float] + pandas series"""
b = pd.Series([True, False, True])
i = pd.Series([2, 3, 5])
f = pd.Series([1.0, 2.0, 3.0])
c = pd.Series([1.1j, 2.2j, 4.1j])

check(assert_type(left + b, "pd.Series[float]"), pd.Series, np.floating)
check(assert_type(left + i, "pd.Series[float]"), pd.Series, np.floating)
Expand Down
Loading
Loading