Skip to content

Commit

Permalink
TST: add tests for inplace ops
Browse files Browse the repository at this point in the history
  • Loading branch information
arw2019 committed Nov 21, 2020
1 parent 668b0e1 commit f0938f6
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions pandas/tests/series/methods/test_inplace_ops.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import pytest

from pandas import Series
import pandas._testing as tm


@pytest.mark.parametrize(
"ser1, ser2, expected_add, expected_sub, expected_mul",
(
[
Series([1], dtype="Int64"),
Series([2], dtype="Int64"),
Series([3], dtype="Int64"),
Series([-1], dtype="Int64"),
Series([2], dtype="Int64"),
],
[
Series([1], dtype="float"),
Series([2.0], dtype="float"),
Series([3.0], dtype="float"),
Series([-1.0], dtype="float"),
Series([2.0], dtype="float"),
],
[
Series([1], dtype="Int64"),
Series([2.0], dtype="float"),
Series([3.0], dtype="float"),
Series([-1.0], dtype="float"),
Series([2], dtype="float"),
],
[
Series([1.0], dtype="float"),
Series([2], dtype="Int64"),
Series([3.0], dtype="float"),
Series([-1.0], dtype="float"),
Series([2], dtype="float"),
],
pytest.param(
Series([1], dtype="Int64"),
Series([2.0], dtype="Float64"),
Series([3.0], dtype="Float64"),
Series([-1.0], dtype="Float64"),
Series([2], dtype="Float64"),
marks=pytest.mark.xfail(reason="Not implemented yet"),
),
),
)
def test_series_inplace_ops(ser1, ser2, expected_add, expected_sub, expected_mul):

res = ser1.copy()
res += ser2
tm.assert_series_equal(res, expected_add)

res = ser1.copy()
res -= ser2
tm.assert_series_equal(res, expected_sub)

res = ser1.copy()
res *= ser2
tm.assert_series_equal(res, expected_mul)

0 comments on commit f0938f6

Please sign in to comment.