Skip to content

Commit 5babe95

Browse files
dalgarnoproost
authored andcommitted
TST: Add docstrings to arithmetic fixtures (pandas-dev#29441)
1 parent db435c8 commit 5babe95

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

pandas/tests/arithmetic/conftest.py

+33-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,24 @@ def id_func(x):
2121

2222
@pytest.fixture(params=[1, np.array(1, dtype=np.int64)])
2323
def one(request):
24-
# zero-dim integer array behaves like an integer
24+
"""
25+
Several variants of integer value 1. The zero-dim integer array
26+
behaves like an integer.
27+
28+
This fixture can be used to check that datetimelike indexes handle
29+
addition and subtraction of integers and zero-dimensional arrays
30+
of integers.
31+
32+
Examples
33+
--------
34+
>>> dti = pd.date_range('2016-01-01', periods=2, freq='H')
35+
>>> dti
36+
DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00'],
37+
dtype='datetime64[ns]', freq='H')
38+
>>> dti + one
39+
DatetimeIndex(['2016-01-01 01:00:00', '2016-01-01 02:00:00'],
40+
dtype='datetime64[ns]', freq='H')
41+
"""
2542
return request.param
2643

2744

@@ -40,8 +57,21 @@ def one(request):
4057

4158
@pytest.fixture(params=zeros)
4259
def zero(request):
43-
# For testing division by (or of) zero for Index with length 5, this
44-
# gives several scalar-zeros and length-5 vector-zeros
60+
"""
61+
Several types of scalar zeros and length 5 vectors of zeros.
62+
63+
This fixture can be used to check that numeric-dtype indexes handle
64+
division by any zero numeric-dtype.
65+
66+
Uses vector of length 5 for broadcasting with `numeric_idx` fixture,
67+
which creates numeric-dtype vectors also of length 5.
68+
69+
Examples
70+
--------
71+
>>> arr = pd.RangeIndex(5)
72+
>>> arr / zeros
73+
Float64Index([nan, inf, inf, inf, inf], dtype='float64')
74+
"""
4575
return request.param
4676

4777

0 commit comments

Comments
 (0)