Skip to content

Commit 43e4953

Browse files
committed
merge upstream master
2 parents 621fb1d + 996f361 commit 43e4953

File tree

148 files changed

+3200
-2074
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+3200
-2074
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ exclude_lines =
1717
# Don't complain if tests don't hit defensive assertion code:
1818
raise AssertionError
1919
raise NotImplementedError
20+
AbstractMethodError
2021

2122
# Don't complain if non-runnable code isn't run:
2223
if 0:

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ dist
6262
coverage.xml
6363
coverage_html_report
6464
*.pytest_cache
65+
# hypothesis test database
66+
.hypothesis/
6567

6668
# OS generated files #
6769
######################

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build: clean_pyc
1313
python setup.py build_ext --inplace
1414

1515
lint-diff:
16-
git diff master --name-only -- "*.py" | grep "pandas" | xargs flake8
16+
git diff master --name-only -- "*.py" | grep -E "pandas|scripts" | xargs flake8
1717

1818
develop: build
1919
-python setup.py develop

ci/appveyor-27.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- matplotlib
1414
- numexpr
1515
- numpy=1.12*
16-
- openpyxl
16+
- openpyxl=2.5.5
1717
- pytables
1818
- python=2.7.*
1919
- pytz
@@ -28,3 +28,4 @@ dependencies:
2828
- pytest
2929
- pytest-xdist
3030
- moto
31+
- hypothesis>=3.58.0

ci/appveyor-36.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- matplotlib
1111
- numexpr
1212
- numpy=1.14*
13-
- openpyxl
13+
- openpyxl=2.5.5
1414
- pyarrow
1515
- pytables
1616
- python-dateutil
@@ -25,3 +25,4 @@ dependencies:
2525
- cython>=0.28.2
2626
- pytest
2727
- pytest-xdist
28+
- hypothesis>=3.58.0

ci/check_imports.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'html5lib',
1010
'ipython',
1111
'jinja2'
12+
'hypothesis',
1213
'lxml',
1314
'numexpr',
1415
'openpyxl',

ci/circle-27-compat.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ dependencies:
77
- cython=0.28.2
88
- jinja2=2.8
99
- numexpr=2.4.4 # we test that we correctly don't use an unsupported numexpr
10-
- numpy=1.9.2
11-
- openpyxl
10+
- numpy=1.9.3
11+
- openpyxl=2.5.5
1212
- psycopg2
1313
- pytables=3.2.2
1414
- python-dateutil=2.5.0
@@ -26,3 +26,4 @@ dependencies:
2626
- html5lib==1.0b2
2727
- beautifulsoup4==4.2.1
2828
- pymysql==0.6.0
29+
- hypothesis>=3.58.0

ci/circle-35-ascii.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ dependencies:
1111
# universal
1212
- pytest
1313
- pytest-xdist
14+
- pip:
15+
- hypothesis>=3.58.0

ci/circle-36-locale.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- nomkl
1414
- numexpr
1515
- numpy
16-
- openpyxl
16+
- openpyxl=2.5.5
1717
- psycopg2
1818
- pymysql
1919
- pytables
@@ -31,3 +31,5 @@ dependencies:
3131
- pytest
3232
- pytest-xdist
3333
- moto
34+
- pip:
35+
- hypothesis>=3.58.0

ci/circle-36-locale_slow.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- nomkl
1515
- numexpr
1616
- numpy
17-
- openpyxl
17+
- openpyxl=2.5.5
1818
- psycopg2
1919
- pymysql
2020
- pytables
@@ -32,3 +32,5 @@ dependencies:
3232
- pytest
3333
- pytest-xdist
3434
- moto
35+
- pip:
36+
- hypothesis>=3.58.0

ci/doctests.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ if [ "$DOCTEST" ]; then
2121

2222
# DataFrame / Series docstrings
2323
pytest --doctest-modules -v pandas/core/frame.py \
24-
-k"-assign -axes -combine -isin -itertuples -join -nlargest -nsmallest -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack -to_dict -to_records -to_stata -transform"
24+
-k"-assign -axes -combine -isin -itertuples -join -nlargest -nsmallest -nunique -pivot_table -quantile -query -reindex -reindex_axis -replace -round -set_index -stack -to_dict -to_stata -transform"
2525

2626
if [ $? -ne "0" ]; then
2727
RET=1
2828
fi
2929

3030
pytest --doctest-modules -v pandas/core/series.py \
31-
-k"-agg -map -nlargest -nonzero -nsmallest -reindex -searchsorted -to_dict"
31+
-k"-nlargest -nonzero -nsmallest -reindex -searchsorted -to_dict"
3232

3333
if [ $? -ne "0" ]; then
3434
RET=1

ci/environment-dev.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dependencies:
77
- NumPy
88
- flake8
99
- flake8-comprehensions
10+
- hypothesis>=3.58.0
1011
- moto
1112
- pytest>=3.6
1213
- python-dateutil>=2.5.0

ci/lint.sh

+11-6
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ if [ "$LINT" ]; then
2020

2121
# pandas/_libs/src is C code, so no need to search there.
2222
echo "Linting *.py"
23-
flake8 pandas --filename=*.py --exclude pandas/_libs/src --ignore=C406,C408,C409,C410,E402,E731,E741,W503
23+
flake8 pandas --filename=*.py --exclude pandas/_libs/src --ignore=C406,C408,C409,E402,E731,E741,W503
24+
if [ $? -ne "0" ]; then
25+
RET=1
26+
fi
27+
28+
flake8 scripts/tests --filename=*.py
2429
if [ $? -ne "0" ]; then
2530
RET=1
2631
fi
2732
echo "Linting *.py DONE"
2833

2934
echo "Linting setup.py"
30-
flake8 setup.py --ignore=C406,C408,C409,C410,E402,E731,E741,W503
35+
flake8 setup.py --ignore=E402,E731,E741,W503
3136
if [ $? -ne "0" ]; then
3237
RET=1
3338
fi
@@ -41,21 +46,21 @@ if [ "$LINT" ]; then
4146
echo "Linting asv_bench/benchmarks/*.py DONE"
4247

4348
echo "Linting scripts/*.py"
44-
flake8 scripts --filename=*.py --ignore=C406,C408,C409,C410,E402,E731,E741,W503
49+
flake8 scripts --filename=*.py --ignore=C408,E402,E731,E741,W503
4550
if [ $? -ne "0" ]; then
4651
RET=1
4752
fi
4853
echo "Linting scripts/*.py DONE"
4954

5055
echo "Linting doc scripts"
51-
flake8 doc/make.py doc/source/conf.py --ignore=C406,C408,C409,C410,E402,E731,E741,W503
56+
flake8 doc/make.py doc/source/conf.py --ignore=E402,E731,E741,W503
5257
if [ $? -ne "0" ]; then
5358
RET=1
5459
fi
5560
echo "Linting doc scripts DONE"
5661

5762
echo "Linting *.pyx"
58-
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C407,C411
63+
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403,C400,C401,C402,C403,C404,C405,C406,C407,C408,C409,C410,C411
5964
if [ $? -ne "0" ]; then
6065
RET=1
6166
fi
@@ -175,7 +180,7 @@ if [ "$LINT" ]; then
175180
RET=1
176181
fi
177182
echo "Check for old-style classes DONE"
178-
183+
179184
echo "Check for backticks incorrectly rendering because of missing spaces"
180185
grep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/
181186

ci/requirements-optional-conda.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lxml
1212
matplotlib
1313
nbsphinx
1414
numexpr
15-
openpyxl
15+
openpyxl=2.5.5
1616
pyarrow
1717
pymysql
1818
pytables

ci/requirements-optional-pip.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ lxml
1414
matplotlib
1515
nbsphinx
1616
numexpr
17-
openpyxl
17+
openpyxl=2.5.5
1818
pyarrow
1919
pymysql
2020
tables
@@ -28,4 +28,4 @@ statsmodels
2828
xarray
2929
xlrd
3030
xlsxwriter
31-
xlwt
31+
xlwt

ci/requirements_dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Cython>=0.28.2
44
NumPy
55
flake8
66
flake8-comprehensions
7+
hypothesis>=3.58.0
78
moto
89
pytest>=3.6
910
python-dateutil>=2.5.0

ci/script_single.sh

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ elif [ "$COVERAGE" ]; then
2828
echo pytest -s -m "single" -r xXs --strict --cov=pandas --cov-report xml:/tmp/cov-single.xml --junitxml=/tmp/single.xml $TEST_ARGS pandas
2929
pytest -s -m "single" -r xXs --strict --cov=pandas --cov-report xml:/tmp/cov-single.xml --junitxml=/tmp/single.xml $TEST_ARGS pandas
3030

31+
echo pytest -s -r xXs --strict scripts
32+
pytest -s -r xXs --strict scripts
3133
else
3234
echo pytest -m "single" -r xXs --junitxml=/tmp/single.xml --strict $TEST_ARGS pandas
3335
pytest -m "single" -r xXs --junitxml=/tmp/single.xml --strict $TEST_ARGS pandas # TODO: doctest

ci/travis-27-locale.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- cython=0.28.2
88
- lxml
99
- matplotlib=1.4.3
10-
- numpy=1.9.2
10+
- numpy=1.9.3
1111
- openpyxl=2.4.0
1212
- python-dateutil
1313
- python-blosc
@@ -22,6 +22,7 @@ dependencies:
2222
# universal
2323
- pytest
2424
- pytest-xdist
25+
- hypothesis>=3.58.0
2526
- pip:
2627
- html5lib==1.0b2
2728
- beautifulsoup4==4.2.1

ci/travis-27.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies:
2929
- PyCrypto
3030
- pymysql=0.6.3
3131
- pytables
32+
- blosc=1.14.3
3233
- python-blosc
3334
- python-dateutil=2.5.0
3435
- python=2.7*
@@ -44,6 +45,7 @@ dependencies:
4445
- pytest
4546
- pytest-xdist
4647
- moto
48+
- hypothesis>=3.58.0
4749
- pip:
4850
- backports.lzma
4951
- cpplint

ci/travis-35-osx.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- nomkl
1313
- numexpr
1414
- numpy=1.10.4
15-
- openpyxl
15+
- openpyxl=2.5.5
1616
- pytables
1717
- python=3.5*
1818
- pytz
@@ -25,3 +25,4 @@ dependencies:
2525
- pytest-xdist
2626
- pip:
2727
- python-dateutil==2.5.3
28+
- hypothesis>=3.58.0

ci/travis-36-doc.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- fastparquet
1111
- feather-format
1212
- html5lib
13+
- hypothesis>=3.58.0
1314
- ipykernel
1415
- ipython
1516
- ipywidgets
@@ -21,7 +22,7 @@ dependencies:
2122
- notebook
2223
- numexpr
2324
- numpy=1.13*
24-
- openpyxl
25+
- openpyxl=2.5.5
2526
- pandoc
2627
- pyqt
2728
- pytables

ci/travis-36-numpydev.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
# universal
99
- pytest
1010
- pytest-xdist
11+
- hypothesis>=3.58.0
1112
- pip:
1213
- "git+git://github.com/dateutil/dateutil.git"
1314
- "-f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"

ci/travis-36-slow.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- matplotlib
1111
- numexpr
1212
- numpy
13-
- openpyxl
13+
- openpyxl=2.5.5
1414
- patsy
1515
- psycopg2
1616
- pymysql
@@ -28,3 +28,4 @@ dependencies:
2828
- pytest
2929
- pytest-xdist
3030
- moto
31+
- hypothesis>=3.58.0

ci/travis-36.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- nomkl
1919
- numexpr
2020
- numpy
21-
- openpyxl
21+
- openpyxl=2.5.5
2222
- psycopg2
2323
- pyarrow
2424
- pymysql
@@ -41,6 +41,7 @@ dependencies:
4141
- pytest-xdist
4242
- pytest-cov
4343
- moto
44+
- hypothesis>=3.58.0
4445
- pip:
4546
- brotlipy
4647
- coverage

ci/travis-37.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dependencies:
1212
- pytz
1313
- pytest
1414
- pytest-xdist
15+
- hypothesis>=3.58.0

doc/source/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,7 @@ Computations / Descriptive Stats
23522352
Resampler.std
23532353
Resampler.sum
23542354
Resampler.var
2355+
Resampler.quantile
23552356

23562357
Style
23572358
-----

doc/source/contributing.rst

+40
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,46 @@ Tests that we have ``parametrized`` are now accessible via the test name, for ex
820820
test_cool_feature.py::test_series[int8] PASSED
821821
822822
823+
.. _using-hypothesis:
824+
825+
Using ``hypothesis``
826+
~~~~~~~~~~~~~~~~~~~~
827+
828+
Hypothesis is a library for property-based testing. Instead of explicitly
829+
parametrizing a test, you can describe *all* valid inputs and let Hypothesis
830+
try to find a failing input. Even better, no matter how many random examples
831+
it tries, Hypothesis always reports a single minimal counterexample to your
832+
assertions - often an example that you would never have thought to test.
833+
834+
See `Getting Started with Hypothesis <https://hypothesis.works/articles/getting-started-with-hypothesis/>`_
835+
for more of an introduction, then `refer to the Hypothesis documentation
836+
for details <https://hypothesis.readthedocs.io/en/latest/index.html>`_.
837+
838+
.. code-block:: python
839+
840+
import json
841+
from hypothesis import given, strategies as st
842+
843+
any_json_value = st.deferred(lambda: st.one_of(
844+
st.none(), st.booleans(), st.floats(allow_nan=False), st.text(),
845+
st.lists(any_json_value), st.dictionaries(st.text(), any_json_value)
846+
))
847+
848+
@given(value=any_json_value)
849+
def test_json_roundtrip(value):
850+
result = json.loads(json.dumps(value))
851+
assert value == result
852+
853+
This test shows off several useful features of Hypothesis, as well as
854+
demonstrating a good use-case: checking properties that should hold over
855+
a large or complicated domain of inputs.
856+
857+
To keep the Pandas test suite running quickly, parametrized tests are
858+
preferred if the inputs or logic are simple, with Hypothesis tests reserved
859+
for cases with complex logic or where there are too many combinations of
860+
options or subtle interactions to test (or think of!) all of them.
861+
862+
823863
Running the test suite
824864
----------------------
825865

0 commit comments

Comments
 (0)