From 44a3e94a75a801c3d1a28491a599abdd8da652df Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Wed, 6 Nov 2019 15:13:16 -0500 Subject: [PATCH 1/6] docs: add docstrings to arithmetic fixtures --- pandas/tests/arithmetic/conftest.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index 774ff14398bdb..b37923a9cdc78 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -21,7 +21,10 @@ def id_func(x): @pytest.fixture(params=[1, np.array(1, dtype=np.int64)]) def one(request): - # zero-dim integer array behaves like an integer + """ + Several variants of integer value 1. The zero-dim integer array + behaves like an integer. + """ return request.param @@ -40,8 +43,10 @@ def one(request): @pytest.fixture(params=zeros) def zero(request): - # For testing division by (or of) zero for Index with length 5, this - # gives several scalar-zeros and length-5 vector-zeros + """ + Several types of scalar zeros and length 5 vectors of zeros. For + testing division by (or of) zero. + """ return request.param From 58148f1b1e87fdec782e2a8ab39e507568dab598 Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Wed, 6 Nov 2019 16:19:56 -0500 Subject: [PATCH 2/6] docs: add example to one fixture --- pandas/tests/arithmetic/conftest.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index b37923a9cdc78..962ffb9b8cb26 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -24,6 +24,22 @@ def one(request): """ Several variants of integer value 1. The zero-dim integer array behaves like an integer. + + This fixture is used to check that datetimelike indexes handle + addition and subtraction of integers and zero-dimensional arrays + of integers. + + Examples + -------- + + >>> dti = pd.date_range('2016-01-01', periods=2, freq='H') + >>> dti + DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00'], + dtype='datetime64[ns]', freq='H') + >>> dti + one + DatetimeIndex(['2016-01-01 01:00:00', '2016-01-01 02:00:00'], + dtype='datetime64[ns]', freq='H') + """ return request.param From 99e6ae2d5bf0a900e8ba1d30223e731e84471437 Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Wed, 6 Nov 2019 16:38:34 -0500 Subject: [PATCH 3/6] docs: add example to zero fixture --- pandas/tests/arithmetic/conftest.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index 962ffb9b8cb26..69e65e7a3b2f5 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -31,7 +31,6 @@ def one(request): Examples -------- - >>> dti = pd.date_range('2016-01-01', periods=2, freq='H') >>> dti DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00'], @@ -39,7 +38,6 @@ def one(request): >>> dti + one DatetimeIndex(['2016-01-01 01:00:00', '2016-01-01 02:00:00'], dtype='datetime64[ns]', freq='H') - """ return request.param @@ -62,6 +60,15 @@ def zero(request): """ Several types of scalar zeros and length 5 vectors of zeros. For testing division by (or of) zero. + + Uses vector of length 5 for broadcasting with `numeric_idx` fixture, + which creates numerical Indexes vectors also of length 5. + + Examples + -------- + >>> arr = pd.RangeIndex(5) + >>> arr / zeros + Float64Index([nan, inf, inf, inf, inf], dtype='float64') """ return request.param From 6a6b93bea10d9d93857656c3901713d60686be33 Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Tue, 12 Nov 2019 21:40:00 +0000 Subject: [PATCH 4/6] docs: extend zero fixture explanation --- pandas/tests/arithmetic/conftest.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index 69e65e7a3b2f5..c6868dc47114d 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -25,7 +25,7 @@ def one(request): Several variants of integer value 1. The zero-dim integer array behaves like an integer. - This fixture is used to check that datetimelike indexes handle + This fixture can be used to check that datetimelike indexes handle addition and subtraction of integers and zero-dimensional arrays of integers. @@ -58,11 +58,13 @@ def one(request): @pytest.fixture(params=zeros) def zero(request): """ - Several types of scalar zeros and length 5 vectors of zeros. For - testing division by (or of) zero. - + Several types of scalar zeros and length 5 vectors of zeros. + + This fixture can be used to check that numeric-dtype indexes handle + division by any zero numeric-dtype. + Uses vector of length 5 for broadcasting with `numeric_idx` fixture, - which creates numerical Indexes vectors also of length 5. + which creates numeric-dtype vectors also of length 5. Examples -------- From f7460eac668d70371f3b286565720befd4e99c30 Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Tue, 12 Nov 2019 21:41:54 +0000 Subject: [PATCH 5/6] style: remove whitespace for lint --- pandas/tests/arithmetic/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index c6868dc47114d..cfc0e0340bf21 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -58,11 +58,11 @@ def one(request): @pytest.fixture(params=zeros) def zero(request): """ - Several types of scalar zeros and length 5 vectors of zeros. - + Several types of scalar zeros and length 5 vectors of zeros. + This fixture can be used to check that numeric-dtype indexes handle division by any zero numeric-dtype. - + Uses vector of length 5 for broadcasting with `numeric_idx` fixture, which creates numeric-dtype vectors also of length 5. From 53f91b91b20ad1acf70f6de0cb4c112432cd47bc Mon Sep 17 00:00:00 2001 From: Alasdair Dalgarno Date: Tue, 12 Nov 2019 21:52:18 +0000 Subject: [PATCH 6/6] style: whitespace --- pandas/tests/arithmetic/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arithmetic/conftest.py b/pandas/tests/arithmetic/conftest.py index cfc0e0340bf21..1f8fdfd671856 100644 --- a/pandas/tests/arithmetic/conftest.py +++ b/pandas/tests/arithmetic/conftest.py @@ -59,7 +59,7 @@ def one(request): def zero(request): """ Several types of scalar zeros and length 5 vectors of zeros. - + This fixture can be used to check that numeric-dtype indexes handle division by any zero numeric-dtype.