Skip to content

Commit 61b252d

Browse files
committed
Add docstrings to fixtures
1 parent de9e91d commit 61b252d

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

pandas/tests/frame/conftest.py

+117
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,40 @@
1414

1515
@pytest.fixture
1616
def frame():
17+
"""
18+
Fixture for DataFrame of floats with index of unique strings
19+
20+
After completing the fixturization of the frame tests (GH 22471), this
21+
fixture will be renamed to: float_frame_string_index
22+
23+
Columns are ['A', 'B', 'C', 'D'], see pandas.util.testing.getSeriesData
24+
"""
1725
return DataFrame(tm.getSeriesData())
1826

1927

2028
@pytest.fixture
2129
def frame2():
30+
"""
31+
Fixture for DataFrame of floats with index of unique strings
32+
33+
After completing the fixturization of the frame tests (GH 22471), this
34+
fixture will be renamed to: float_frame_string_index2
35+
36+
Columns are ['D', 'C', 'B', 'A']. See pandas.util.testing.getSeriesData
37+
"""
2238
return DataFrame(tm.getSeriesData(), columns=['D', 'C', 'B', 'A'])
2339

2440

2541
@pytest.fixture
2642
def intframe():
43+
"""
44+
Fixture for DataFrame of ints with index of unique strings
45+
46+
After completing the fixturization of the frame tests (GH 22471), this
47+
fixture will be renamed to: int_frame
48+
49+
Columns are ['A', 'B', 'C', 'D']. See pandas.util.testing.getSeriesData
50+
"""
2751
df = DataFrame({k: v.astype(int)
2852
for k, v in compat.iteritems(tm.getSeriesData())})
2953
# force these all to int64 to avoid platform testing issues
@@ -32,18 +56,43 @@ def intframe():
3256

3357
@pytest.fixture
3458
def tsframe():
59+
"""
60+
Fixture for DataFrame of floats with DatetimeIndex
61+
62+
After completing the fixturization of the frame tests (GH 22471), this
63+
fixture will be renamed to: float_frame_datetime_index
64+
65+
Columns are ['A', 'B', 'C', 'D']. See pandas.util.testing.getTimeSeriesData
66+
"""
3567
return DataFrame(tm.getTimeSeriesData())
3668

3769

3870
@pytest.fixture
3971
def mixed_frame():
72+
"""
73+
Fixture for DataFrame of floats and strings with string index
74+
75+
After completing the fixturization of the frame tests (GH 22471), this
76+
fixture will be renamed to: float_string_frame
77+
78+
Columns are ['A', 'B', 'C', 'D', 'foo'].
79+
See pandas.util.testing.getSeriesData
80+
"""
4081
df = DataFrame(tm.getSeriesData())
4182
df['foo'] = 'bar'
4283
return df
4384

4485

4586
@pytest.fixture
4687
def mixed_float():
88+
"""
89+
Fixture for DataFrame of different float types with string index
90+
91+
After completing the fixturization of the frame tests (GH 22471), this
92+
fixture will be renamed to: mixed_float_frame
93+
94+
Columns are ['A', 'B', 'C', 'D']. See pandas.util.testing.getSeriesData
95+
"""
4796
df = DataFrame(tm.getSeriesData())
4897
df.A = df.A.astype('float16')
4998
df.B = df.B.astype('float32')
@@ -53,6 +102,14 @@ def mixed_float():
53102

54103
@pytest.fixture
55104
def mixed_float2():
105+
"""
106+
Fixture for DataFrame of different float types with string index
107+
108+
After completing the fixturization of the frame tests (GH 22471), this
109+
fixture will be renamed to: mixed_float_frame2
110+
111+
Columns are ['A', 'B', 'C', 'D']. See pandas.util.testing.getSeriesData
112+
"""
56113
df = DataFrame(tm.getSeriesData())
57114
df.D = df.D.astype('float16')
58115
df.C = df.C.astype('float32')
@@ -62,6 +119,14 @@ def mixed_float2():
62119

63120
@pytest.fixture
64121
def mixed_int():
122+
"""
123+
Fixture for DataFrame of different int types with string index
124+
125+
After completing the fixturization of the frame tests (GH 22471), this
126+
fixture will be renamed to: mixed_int_frame
127+
128+
Columns are ['A', 'B', 'C', 'D']. See pandas.util.testing.getSeriesData
129+
"""
65130
df = DataFrame({k: v.astype(int)
66131
for k, v in compat.iteritems(tm.getSeriesData())})
67132
df.A = df.A.astype('uint8')
@@ -73,6 +138,14 @@ def mixed_int():
73138

74139
@pytest.fixture
75140
def all_mixed():
141+
"""
142+
Fixture for DataFrame of float/int/string columns
143+
144+
After completing the fixturization of the frame tests (GH 22471), this
145+
fixture will be renamed to: float_int_string_frame
146+
147+
Columns are ['a', 'b', 'c', 'float32', 'int32'].
148+
"""
76149
return DataFrame({'a': 1., 'b': 2, 'c': 'foo',
77150
'float32': np.array([1.] * 10, dtype='float32'),
78151
'int32': np.array([1] * 10, dtype='int32')},
@@ -81,6 +154,14 @@ def all_mixed():
81154

82155
@pytest.fixture
83156
def tzframe():
157+
"""
158+
Fixture for DataFrame of date_range Series with different timezones
159+
160+
After completing the fixturization of the frame tests (GH 22471), this
161+
fixture will be renamed to: timezone_frame
162+
163+
Columns are ['A', 'B', 'C']; some entries are missing
164+
"""
84165
df = DataFrame({'A': date_range('20130101', periods=3),
85166
'B': date_range('20130101', periods=3,
86167
tz='US/Eastern'),
@@ -93,21 +174,51 @@ def tzframe():
93174

94175
@pytest.fixture
95176
def empty():
177+
"""
178+
Fixture for empty DataFrame
179+
180+
After completing the fixturization of the frame tests (GH 22471), this
181+
fixture will be renamed to: empty_frame
182+
"""
96183
return DataFrame({})
97184

98185

99186
@pytest.fixture
100187
def ts1():
188+
"""
189+
Fixture for Series of floats with DatetimeIndex
190+
191+
After completing the fixturization of the frame tests (GH 22471), this
192+
fixture will be renamed to: datetime_series
193+
194+
See pandas.util.testing.makeTimeSeries
195+
"""
101196
return tm.makeTimeSeries(nper=30)
102197

103198

104199
@pytest.fixture
105200
def ts2():
201+
"""
202+
Fixture for Series of floats with DatetimeIndex
203+
204+
After completing the fixturization of the frame tests (GH 22471), this
205+
fixture will be renamed to: datetime_series_short
206+
207+
See pandas.util.testing.makeTimeSeries
208+
"""
106209
return tm.makeTimeSeries(nper=30)[5:]
107210

108211

109212
@pytest.fixture
110213
def simple():
214+
"""
215+
Fixture for simple 3x3 DataFrame
216+
217+
After completing the fixturization of the frame tests (GH 22471), this
218+
fixture will be renamed to: simple_frame
219+
220+
Columns are ['one', 'two', 'three'], index is ['a', 'b', 'c'].
221+
"""
111222
arr = np.array([[1., 2., 3.],
112223
[4., 5., 6.],
113224
[7., 8., 9.]])
@@ -118,6 +229,12 @@ def simple():
118229

119230
@pytest.fixture
120231
def frame_of_index_cols():
232+
"""
233+
Fixture for DataFrame of columns that can be used for indexing
234+
235+
Columns are ['A', 'B', 'C', 'D', 'E']; 'A' & 'B' contain duplicates,
236+
the rest are unique.
237+
"""
121238
df = DataFrame({'A': ['foo', 'foo', 'foo', 'bar', 'bar'],
122239
'B': ['one', 'two', 'three', 'one', 'two'],
123240
'C': ['a', 'b', 'c', 'd', 'e'],

0 commit comments

Comments
 (0)