Skip to content

Commit c3d7d25

Browse files
authored
TST: misplaced Series.get test (#32876)
1 parent 2784006 commit c3d7d25

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

pandas/tests/generic/test_series.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ def finalize(self, other, method=None, **kwargs):
176176
Series._metadata = _metadata
177177
Series.__finalize__ = _finalize # FIXME: use monkeypatch
178178

179+
180+
class TestSeries2:
181+
# Separating off because it doesnt rely on parent class
179182
@pytest.mark.parametrize(
180183
"s",
181184
[
@@ -196,26 +199,6 @@ def test_datetime_shift_always_copy(self, move_by_freq):
196199
assert s.shift(freq=move_by_freq) is not s
197200

198201

199-
class TestSeries2:
200-
# moved from Generic
201-
def test_get_default(self):
202-
203-
# GH#7725
204-
d0 = ["a", "b", "c", "d"]
205-
d1 = np.arange(4, dtype="int64")
206-
others = ["e", 10]
207-
208-
for data, index in ((d0, d1), (d1, d0)):
209-
s = Series(data, index=index)
210-
for i, d in zip(index, data):
211-
assert s.get(i) == d
212-
assert s.get(i, d) == d
213-
assert s.get(i, "z") == d
214-
for other in others:
215-
assert s.get(other, "z") == "z"
216-
assert s.get(other, other) == other
217-
218-
219202
class TestToXArray:
220203
@pytest.mark.skipif(
221204
not _XARRAY_INSTALLED

pandas/tests/series/indexing/test_get.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,20 @@ def test_get_nan_multiple():
132132

133133
idx = [np.nan, np.nan]
134134
assert s.get(idx) is None
135+
136+
137+
def test_get_with_default():
138+
# GH#7725
139+
d0 = ["a", "b", "c", "d"]
140+
d1 = np.arange(4, dtype="int64")
141+
others = ["e", 10]
142+
143+
for data, index in ((d0, d1), (d1, d0)):
144+
s = Series(data, index=index)
145+
for i, d in zip(index, data):
146+
assert s.get(i) == d
147+
assert s.get(i, d) == d
148+
assert s.get(i, "z") == d
149+
for other in others:
150+
assert s.get(other, "z") == "z"
151+
assert s.get(other, other) == other

pandas/tests/series/test_timeseries.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
import pandas._testing as tm
77

88

9-
def _simple_ts(start, end, freq="D"):
10-
rng = date_range(start, end, freq=freq)
11-
return Series(np.random.randn(len(rng)), index=rng)
12-
13-
14-
def assert_range_equal(left, right):
15-
assert left.equals(right)
16-
assert left.freq == right.freq
17-
assert left.tz == right.tz
18-
19-
209
class TestTimeSeries:
2110
def test_mpl_compat_hack(self, datetime_series):
2211

@@ -44,8 +33,8 @@ def test_contiguous_boolean_preserve_freq(self):
4433

4534
masked = rng[mask]
4635
expected = rng[10:20]
47-
assert expected.freq is not None
48-
assert_range_equal(masked, expected)
36+
assert expected.freq == rng.freq
37+
tm.assert_index_equal(masked, expected)
4938

5039
mask[22] = True
5140
masked = rng[mask]

0 commit comments

Comments
 (0)