Skip to content

Commit

Permalink
Added tests back in
Browse files Browse the repository at this point in the history
Tests should be red now
  • Loading branch information
cchwala committed Aug 25, 2020
1 parent 8ceff58 commit 7c5ad7d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pandas/tests/series/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,60 @@ def test_interp_limit_direction_raises(self, method, limit_direction, expected):
with pytest.raises(ValueError, match=msg):
s.interpolate(method=method, limit_direction=limit_direction)

def test_interp_limit_area_with_pad(self):
# Test for issue #26796
s = Series(
[np.nan, np.nan, 3, np.nan, np.nan, np.nan, 7, np.nan, np.nan])

expected = Series(
[np.nan, np.nan, 3.0, 3.0, 3.0, 3.0, 7.0, np.nan, np.nan])
result = s.interpolate(method="pad", limit_area="inside")
tm.assert_series_equal(result, expected)

expected = Series(
[np.nan, np.nan, 3.0, 3.0, np.nan, np.nan, 7.0, np.nan, np.nan]
)
result = s.interpolate(method="pad", limit_area="inside", limit=1)
tm.assert_series_equal(result, expected)

expected = Series(
[np.nan, np.nan, 3.0, np.nan, np.nan, np.nan, 7.0, 7.0, 7.0])
result = s.interpolate(method="pad", limit_area="outside")
tm.assert_series_equal(result, expected)

expected = Series(
[np.nan, np.nan, 3.0, np.nan, np.nan, np.nan, 7.0, 7.0, np.nan]
)
result = s.interpolate(method="pad", limit_area="outside", limit=1)
tm.assert_series_equal(result, expected)

def test_interp_limit_area_with_backfill(self):
# Test for issue #26796
s = Series(
[np.nan, np.nan, 3, np.nan, np.nan, np.nan, 7, np.nan, np.nan])

expected = Series(
[np.nan, np.nan, 3.0, 7.0, 7.0, 7.0, 7.0, np.nan, np.nan])
result = s.interpolate(method="bfill", limit_area="inside")
tm.assert_series_equal(result, expected)

expected = Series(
[np.nan, np.nan, 3.0, np.nan, np.nan, 7.0, 7.0, np.nan, np.nan]
)
result = s.interpolate(method="bfill", limit_area="inside", limit=1)
tm.assert_series_equal(result, expected)

expected = Series(
[3.0, 3.0, 3.0, np.nan, np.nan, np.nan, 7.0, np.nan, np.nan])
result = s.interpolate(method="bfill", limit_area="outside")
tm.assert_series_equal(result, expected)

expected = Series(
[np.nan, 3.0, 3.0, np.nan, np.nan, np.nan, 7.0, np.nan, np.nan]
)
result = s.interpolate(method="bfill", limit_area="outside", limit=1)
tm.assert_series_equal(result, expected)

def test_interp_limit_direction(self):
# These tests are for issue #9218 -- fill NaNs in both directions.
s = Series([1, 3, np.nan, np.nan, np.nan, 11])
Expand Down

0 comments on commit 7c5ad7d

Please sign in to comment.