Skip to content

Commit 3f06c9b

Browse files
committed
Revert "Move tests"
This reverts commit 15e919d.
1 parent 6f25bc5 commit 3f06c9b

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

pandas/tests/frame/methods/test_truncate.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,15 @@ def test_truncate_nonsortedindex(self):
8787
msg = "truncate requires a sorted index"
8888
with pytest.raises(ValueError, match=msg):
8989
df.truncate(before=2, after=20, axis=1)
90+
91+
@pytest.mark.parametrize(
92+
"before, after, indices",
93+
[(1, 2, [2, 1]), (None, 2, [2, 1, 0]), (1, None, [3, 2, 1])],
94+
)
95+
def test_truncate_decreasing_index(self, before, after, indices):
96+
# https://github.com/pandas-dev/pandas/issues/33756
97+
idx = pd.Index([3, 2, 1, 0])
98+
values = pd.DataFrame(range(len(idx)), index=idx)
99+
result = values.truncate(before=before, after=after)
100+
expected = values.loc[indices]
101+
tm.assert_frame_equal(result, expected)

pandas/tests/generic/methods/test_truncate.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

pandas/tests/series/methods/test_truncate.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ def test_truncate_nonsortedindex(self):
8080
with pytest.raises(ValueError, match=msg):
8181
ts.sort_values(ascending=False).truncate(before="2011-11", after="2011-12")
8282

83+
@pytest.mark.parametrize(
84+
"before, after, indices",
85+
[(1, 2, [2, 1]), (None, 2, [2, 1, 0]), (1, None, [3, 2, 1])],
86+
)
87+
def test_truncate_decreasing_index(self, before, after, indices):
88+
# https://github.com/pandas-dev/pandas/issues/33756
89+
idx = pd.Index([3, 2, 1, 0])
90+
values = pd.Series(range(len(idx)), index=idx)
91+
result = values.truncate(before=before, after=after)
92+
expected = values.loc[indices]
93+
tm.assert_series_equal(result, expected)
94+
8395
def test_truncate_datetimeindex_tz(self):
8496
# GH 9243
8597
idx = date_range("4/1/2005", "4/30/2005", freq="D", tz="US/Pacific")

0 commit comments

Comments
 (0)