Skip to content

Commit c3f492f

Browse files
jbrockmendelWillAyd
authored andcommitted
REF: move misplaced tests (#31189)
1 parent e31c5ad commit c3f492f

File tree

5 files changed

+59
-54
lines changed

5 files changed

+59
-54
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pytest
2+
3+
from pandas import DatetimeIndex, date_range
4+
import pandas._testing as tm
5+
6+
7+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
8+
@pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"])
9+
@pytest.mark.parametrize("name", [None, "my_dti"])
10+
def test_dti_snap(name, tz):
11+
dti = DatetimeIndex(
12+
[
13+
"1/1/2002",
14+
"1/2/2002",
15+
"1/3/2002",
16+
"1/4/2002",
17+
"1/5/2002",
18+
"1/6/2002",
19+
"1/7/2002",
20+
],
21+
name=name,
22+
tz=tz,
23+
freq="D",
24+
)
25+
26+
result = dti.snap(freq="W-MON")
27+
expected = date_range("12/31/2001", "1/7/2002", name=name, tz=tz, freq="w-mon")
28+
expected = expected.repeat([3, 4])
29+
tm.assert_index_equal(result, expected)
30+
assert result.tz == expected.tz
31+
32+
result = dti.snap(freq="B")
33+
34+
expected = date_range("1/1/2002", "1/7/2002", name=name, tz=tz, freq="b")
35+
expected = expected.repeat([1, 1, 1, 2, 2])
36+
tm.assert_index_equal(result, expected)
37+
assert result.tz == expected.tz

pandas/tests/indexes/multi/test_setops.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ def test_symmetric_difference(idx, sort):
110110
first.symmetric_difference([1, 2, 3], sort=sort)
111111

112112

113+
def test_multiindex_symmetric_difference():
114+
# GH 13490
115+
idx = MultiIndex.from_product([["a", "b"], ["A", "B"]], names=["a", "b"])
116+
result = idx ^ idx
117+
assert result.names == idx.names
118+
119+
idx2 = idx.copy().rename(["A", "B"])
120+
result = idx ^ idx2
121+
assert result.names == [None, None]
122+
123+
113124
def test_empty(idx):
114125
# GH 15270
115126
assert not idx.empty

pandas/tests/indexing/multiindex/test_set_ops.py renamed to pandas/tests/indexing/multiindex/test_insert.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@
44
import pandas._testing as tm
55

66

7-
class TestMultiIndexSetOps:
8-
def test_multiindex_symmetric_difference(self):
9-
# GH 13490
10-
idx = MultiIndex.from_product([["a", "b"], ["A", "B"]], names=["a", "b"])
11-
result = idx ^ idx
12-
assert result.names == idx.names
13-
14-
idx2 = idx.copy().rename(["A", "B"])
15-
result = idx ^ idx2
16-
assert result.names == [None, None]
17-
7+
class TestMultiIndexInsertion:
188
def test_mixed_depth_insert(self):
199
arrays = [
2010
["a", "top", "top", "routine1", "routine1", "routine2"],

pandas/tests/series/indexing/test_datetime.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,6 @@ def test_fancy_setitem():
4949
assert (s[48:54] == -3).all()
5050

5151

52-
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
53-
@pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"])
54-
@pytest.mark.parametrize("name", [None, "my_dti"])
55-
def test_dti_snap(name, tz):
56-
dti = DatetimeIndex(
57-
[
58-
"1/1/2002",
59-
"1/2/2002",
60-
"1/3/2002",
61-
"1/4/2002",
62-
"1/5/2002",
63-
"1/6/2002",
64-
"1/7/2002",
65-
],
66-
name=name,
67-
tz=tz,
68-
freq="D",
69-
)
70-
71-
result = dti.snap(freq="W-MON")
72-
expected = date_range("12/31/2001", "1/7/2002", name=name, tz=tz, freq="w-mon")
73-
expected = expected.repeat([3, 4])
74-
tm.assert_index_equal(result, expected)
75-
assert result.tz == expected.tz
76-
77-
result = dti.snap(freq="B")
78-
79-
expected = date_range("1/1/2002", "1/7/2002", name=name, tz=tz, freq="b")
80-
expected = expected.repeat([1, 1, 1, 2, 2])
81-
tm.assert_index_equal(result, expected)
82-
assert result.tz == expected.tz
83-
84-
8552
def test_dti_reset_index_round_trip():
8653
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")
8754
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
@@ -751,16 +718,6 @@ def test_nat_operations():
751718
assert s.max() == exp
752719

753720

754-
@pytest.mark.parametrize("method", ["round", "floor", "ceil"])
755-
@pytest.mark.parametrize("freq", ["s", "5s", "min", "5min", "h", "5h"])
756-
def test_round_nat(method, freq):
757-
# GH14940
758-
s = Series([pd.NaT])
759-
expected = Series(pd.NaT)
760-
round_method = getattr(s.dt, method)
761-
tm.assert_series_equal(round_method(freq), expected)
762-
763-
764721
def test_setitem_tuple_with_datetimetz():
765722
# GH 20441
766723
arr = date_range("2017", periods=4, tz="US/Eastern")

pandas/tests/series/methods/test_round.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import pytest
33

4+
import pandas as pd
45
from pandas import Series
56
import pandas._testing as tm
67

@@ -44,3 +45,12 @@ def test_round_builtin(self):
4445
expected_rounded = Series([1.12, 2.12, 3.12], index=range(3))
4546
result = round(ser, decimals)
4647
tm.assert_series_equal(result, expected_rounded)
48+
49+
@pytest.mark.parametrize("method", ["round", "floor", "ceil"])
50+
@pytest.mark.parametrize("freq", ["s", "5s", "min", "5min", "h", "5h"])
51+
def test_round_nat(self, method, freq):
52+
# GH14940
53+
ser = Series([pd.NaT])
54+
expected = Series(pd.NaT)
55+
round_method = getattr(ser.dt, method)
56+
tm.assert_series_equal(round_method(freq), expected)

0 commit comments

Comments
 (0)