Skip to content

Commit 89be1f0

Browse files
authored
DOC: Added docstrings to fixtures defined in array module (#47211)
1 parent 72e84c4 commit 89be1f0

17 files changed

+84
-3
lines changed

pandas/tests/arrays/boolean/test_arithmetic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@pytest.fixture
1111
def data():
12+
"""Fixture returning boolean array with valid and missing values."""
1213
return pd.array(
1314
[True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
1415
dtype="boolean",
@@ -17,11 +18,13 @@ def data():
1718

1819
@pytest.fixture
1920
def left_array():
21+
"""Fixture returning boolean array with valid and missing values."""
2022
return pd.array([True] * 3 + [False] * 3 + [None] * 3, dtype="boolean")
2123

2224

2325
@pytest.fixture
2426
def right_array():
27+
"""Fixture returning boolean array with valid and missing values."""
2528
return pd.array([True, False, None] * 3, dtype="boolean")
2629

2730

pandas/tests/arrays/boolean/test_comparison.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@pytest.fixture
1111
def data():
12+
"""Fixture returning boolean array with valid and missing data"""
1213
return pd.array(
1314
[True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
1415
dtype="boolean",
@@ -17,6 +18,7 @@ def data():
1718

1819
@pytest.fixture
1920
def dtype():
21+
"""Fixture returning BooleanDtype"""
2022
return pd.BooleanDtype()
2123

2224

pandas/tests/arrays/boolean/test_reduction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
@pytest.fixture
88
def data():
9+
"""Fixture returning boolean array, with valid and missing values."""
910
return pd.array(
1011
[True, False] * 4 + [np.nan] + [True, False] * 44 + [np.nan] + [True, False],
1112
dtype="boolean",

pandas/tests/arrays/categorical/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ def allow_fill(request):
1111

1212
@pytest.fixture
1313
def factor():
14+
"""Fixture returning a Categorical object"""
1415
return Categorical(["a", "b", "b", "a", "a", "c", "c", "c"], ordered=True)

pandas/tests/arrays/datetimes/test_reductions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
class TestReductions:
1313
@pytest.fixture
1414
def arr1d(self, tz_naive_fixture):
15+
"""Fixture returning DatetimeArray with parametrized timezones"""
1516
tz = tz_naive_fixture
1617
dtype = DatetimeTZDtype(tz=tz) if tz is not None else np.dtype("M8[ns]")
1718
arr = DatetimeArray._from_sequence(

pandas/tests/arrays/floating/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010

1111
@pytest.fixture(params=[Float32Dtype, Float64Dtype])
1212
def dtype(request):
13+
"""Parametrized fixture returning a float 'dtype'"""
1314
return request.param()
1415

1516

1617
@pytest.fixture
1718
def data(dtype):
19+
"""Fixture returning 'data' array according to parametrized float 'dtype'"""
1820
return pd.array(
1921
list(np.arange(0.1, 0.9, 0.1))
2022
+ [pd.NA]
@@ -27,12 +29,19 @@ def data(dtype):
2729

2830
@pytest.fixture
2931
def data_missing(dtype):
32+
"""
33+
Fixture returning array with missing data according to parametrized float
34+
'dtype'.
35+
"""
3036
return pd.array([np.nan, 0.1], dtype=dtype)
3137

3238

3339
@pytest.fixture(params=["data", "data_missing"])
3440
def all_data(request, data, data_missing):
35-
"""Parametrized fixture giving 'data' and 'data_missing'"""
41+
"""Parametrized fixture returning 'data' or 'data_missing' float arrays.
42+
43+
Used to test dtype conversion with and without missing values.
44+
"""
3645
if request.param == "data":
3746
return data
3847
elif request.param == "data_missing":

pandas/tests/arrays/integer/conftest.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@
2727
]
2828
)
2929
def dtype(request):
30+
"""Parametrized fixture returning integer 'dtype'"""
3031
return request.param()
3132

3233

3334
@pytest.fixture
3435
def data(dtype):
36+
"""
37+
Fixture returning 'data' array with valid and missing values according to
38+
parametrized integer 'dtype'.
39+
40+
Used to test dtype conversion with and without missing values.
41+
"""
3542
return pd.array(
3643
list(range(8)) + [np.nan] + list(range(10, 98)) + [np.nan] + [99, 100],
3744
dtype=dtype,
@@ -40,12 +47,21 @@ def data(dtype):
4047

4148
@pytest.fixture
4249
def data_missing(dtype):
50+
"""
51+
Fixture returning array with exactly one NaN and one valid integer,
52+
according to parametrized integer 'dtype'.
53+
54+
Used to test dtype conversion with and without missing values.
55+
"""
4356
return pd.array([np.nan, 1], dtype=dtype)
4457

4558

4659
@pytest.fixture(params=["data", "data_missing"])
4760
def all_data(request, data, data_missing):
48-
"""Parametrized fixture giving 'data' and 'data_missing'"""
61+
"""Parametrized fixture returning 'data' or 'data_missing' integer arrays.
62+
63+
Used to test dtype conversion with and without missing values.
64+
"""
4965
if request.param == "data":
5066
return data
5167
elif request.param == "data_missing":

pandas/tests/arrays/integer/test_construction.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
@pytest.fixture(params=[pd.array, IntegerArray._from_sequence])
1616
def constructor(request):
17+
"""Fixture returning parametrized IntegerArray from given sequence.
18+
19+
Used to test dtype conversions.
20+
"""
1721
return request.param
1822

1923

pandas/tests/arrays/masked/test_arithmetic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222
@pytest.fixture(params=zip(arrays, scalars), ids=[a.dtype.name for a in arrays])
2323
def data(request):
24+
"""Fixture returning parametrized (array, scalar) tuple.
25+
26+
Used to test equivalence of scalars, numpy arrays with array ops, and the
27+
equivalence of DataFrame and Series ops.
28+
"""
2429
return request.param
2530

2631

pandas/tests/arrays/masked/test_arrow_compat.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
@pytest.fixture(params=arrays, ids=[a.dtype.name for a in arrays])
1717
def data(request):
18+
"""
19+
Fixture returning parametrized array from given dtype, including integer,
20+
float and boolean
21+
"""
1822
return request.param
1923

2024

@@ -101,6 +105,10 @@ def test_arrow_sliced(data):
101105

102106
@pytest.fixture
103107
def np_dtype_to_arrays(any_real_numpy_dtype):
108+
"""
109+
Fixture returning actual and expected dtype, pandas and numpy arrays and
110+
mask from a given numpy dtype
111+
"""
104112
np_dtype = np.dtype(any_real_numpy_dtype)
105113
pa_type = pa.from_numpy_dtype(np_dtype)
106114

0 commit comments

Comments
 (0)