Skip to content

DOC/CI: run doctests on travis #19952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f17747f
let doctest fail travis if they fail
jorisvandenbossche Mar 1, 2018
d24bbd2
remove check for building docs, we also want to test if docstrings ch…
jorisvandenbossche Mar 1, 2018
47f7034
Add Series and DataFrame doctests
jorisvandenbossche Mar 1, 2018
67f4ae8
try propagating exit value
jorisvandenbossche Mar 1, 2018
5caf04b
move to separate file
jorisvandenbossche Apr 9, 2018
2d4c6ac
Merge remote-tracking branch 'upstream/master' into doctests-travis
jorisvandenbossche Apr 9, 2018
10cf824
add read functions
jorisvandenbossche Apr 9, 2018
32f6d1c
run doctests on python 3.6 build
jorisvandenbossche Apr 9, 2018
5833f86
ensure doctest collection does not fail
jorisvandenbossche Apr 10, 2018
1d8e592
temp: check running all doctests on travis
jorisvandenbossche Apr 10, 2018
3add36c
cummax giving core dump
jorisvandenbossche Apr 10, 2018
a65ee48
Merge remote-tracking branch 'upstream/master' into doctests-travis
jorisvandenbossche Jul 8, 2018
9317d31
try
jorisvandenbossche Jul 8, 2018
7845ea3
remove snippet that causes segfault
jorisvandenbossche Jul 9, 2018
6cc5a96
Merge remote-tracking branch 'upstream/master' into doctests-travis
jorisvandenbossche Aug 15, 2018
9837682
fix DataFrame docstring
jorisvandenbossche Aug 16, 2018
5d468d2
test checking all frame docstrings with skipped ones
jorisvandenbossche Aug 16, 2018
6826dcf
add series + generic
jorisvandenbossche Aug 16, 2018
834c750
Merge branch 'master' of https://github.com/pandas-dev/pandas into do…
jorisvandenbossche Aug 16, 2018
c03c895
also skip xs
jorisvandenbossche Aug 16, 2018
d3d5a50
clean-up
jorisvandenbossche Aug 16, 2018
4884f03
add short docs about testing/validating docstrings
jorisvandenbossche Aug 16, 2018
caa43f1
typo
jorisvandenbossche Aug 16, 2018
25bc158
skip describe
jorisvandenbossche Aug 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ matrix:
- python-gtk2
- dist: trusty
env:
- JOB="3.6, coverage" ENV_FILE="ci/travis-36.yaml" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true
- JOB="3.6, coverage" ENV_FILE="ci/travis-36.yaml" TEST_ARGS="--skip-slow --skip-network" PANDAS_TESTING_MODE="deprecate" COVERAGE=true DOCTEST=true
# In allow_failures
- dist: trusty
env:
Expand Down Expand Up @@ -119,6 +119,7 @@ script:
- ci/script_single.sh
- ci/script_multi.sh
- ci/lint.sh
- ci/doctests.sh
- echo "checking imports"
- source activate pandas && python ci/check_imports.py
- echo "script done"
Expand Down
18 changes: 0 additions & 18 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ fi
cd "$TRAVIS_BUILD_DIR"
echo "inside $0"

git show --pretty="format:" --name-only HEAD~5.. --first-parent | grep -P "rst|txt|doc"

# if [ "$?" != "0" ]; then
# echo "Skipping doc build, none were modified"
# # nope, skip docs build
# exit 0
# fi


if [ "$DOC" ]; then

echo "Will build docs"
Expand Down Expand Up @@ -60,15 +51,6 @@ if [ "$DOC" ]; then
git remote -v

git push origin gh-pages -f

echo "Running doctests"
cd "$TRAVIS_BUILD_DIR"
pytest --doctest-modules \
pandas/core/reshape/concat.py \
pandas/core/reshape/pivot.py \
pandas/core/reshape/reshape.py \
pandas/core/reshape/tile.py

fi

exit 0
67 changes: 67 additions & 0 deletions ci/doctests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

echo "inside $0"


source activate pandas
cd "$TRAVIS_BUILD_DIR"

RET=0

if [ "$DOCTEST" ]; then

echo "Running doctests"

# pytest --doctest-modules --ignore=pandas/tests -v pandas/core/frame.py

# if [ $? -ne "0" ]; then
# RET=1
# fi


# # top-level reshaping functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these just not-working tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, they are failing, and don't want to start fixing all of them here. Will remove or either skip the failing ones

# pytest --doctest-modules -v \
# pandas/core/reshape/concat.py \
# pandas/core/reshape/pivot.py \
# pandas/core/reshape/reshape.py \
# pandas/core/reshape/tile.py

# if [ $? -ne "0" ]; then
# RET=1
# fi

# # top-level io functionality
# pytest --doctest-modules -v pandas/io/* -k "read_"

# if [ $? -ne "0" ]; then
# RET=1
# fi

# DataFrame docstrings
pytest --doctest-modules -v pandas/core/frame.py \
-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"

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

# Series docstrings
pytest --doctest-modules -v pandas/core/series.py \
-k"-agg -map -nlargest -nonzero -nsmallest -reindex -searchsorted -to_dict"

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

pytest --doctest-modules -v pandas/core/generic.py \
-k"-_set_axis_name -_xs -droplevel -groupby -interpolate -pct_change -pipe -reindex -reindex_axis -resample -sample -to_json -to_xarray -transform -transpose -values"

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

else
echo "NOT running doctests"
fi

exit $RET
2 changes: 1 addition & 1 deletion pandas/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class option_context(object):
--------

>>> with option_context('display.max_rows', 10, 'display.max_columns', 5):
...
... ...

"""

Expand Down
14 changes: 6 additions & 8 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,13 @@ class DataFrame(NDFrame):

Constructing DataFrame from numpy ndarray:

>>> df2 = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)),
... columns=['a', 'b', 'c', 'd', 'e'])
>>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
... columns=['a', 'b', 'c'])
>>> df2
a b c d e
0 2 8 8 3 4
1 4 2 9 0 9
2 1 0 7 8 0
3 5 1 7 1 3
4 6 0 2 4 2
a b c
0 1 2 3
1 4 5 6
2 7 8 9

See also
--------
Expand Down
12 changes: 6 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,14 @@ def droplevel(self, level, axis=0):
Examples
--------
>>> df = pd.DataFrame([
...: [1, 2, 3, 4],
...: [5, 6, 7, 8],
...: [9, 10, 11, 12]
...: ]).set_index([0, 1]).rename_axis(['a', 'b'])
... [1, 2, 3, 4],
... [5, 6, 7, 8],
... [9, 10, 11, 12]
... ]).set_index([0, 1]).rename_axis(['a', 'b'])

>>> df.columns = pd.MultiIndex.from_tuples([
...: ('c', 'e'), ('d', 'f')
...:], names=['level_1', 'level_2'])
... ('c', 'e'), ('d', 'f')
... ], names=['level_1', 'level_2'])

>>> df
level_1 c d
Expand Down
9 changes: 4 additions & 5 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def set_defaultencoding(encoding):


def capture_stdout(f):
"""
r"""
Decorator to capture stdout in a buffer so that it can be checked
(or suppressed) during testing.

Expand All @@ -609,7 +609,6 @@ def capture_stdout(f):
--------

>>> from pandas.util.testing import capture_stdout
>>>
>>> import sys
>>>
>>> @capture_stdout
Expand Down Expand Up @@ -639,7 +638,7 @@ def wrapper(*args, **kwargs):


def capture_stderr(f):
"""
r"""
Decorator to capture stderr in a buffer so that it can be checked
(or suppressed) during testing.

Expand All @@ -657,7 +656,6 @@ def capture_stderr(f):
--------

>>> from pandas.util.testing import capture_stderr
>>>
>>> import sys
>>>
>>> @capture_stderr
Expand Down Expand Up @@ -2370,7 +2368,7 @@ def wrapper(*args, **kwargs):

def assert_raises_regex(_exception, _regexp, _callable=None,
*args, **kwargs):
r"""
"""
Check that the specified Exception is raised and that the error message
matches a given regular expression pattern. This may be a regular
expression object or a string containing a regular expression suitable
Expand All @@ -2396,6 +2394,7 @@ def assert_raises_regex(_exception, _regexp, _callable=None,
AssertionError: "pear" does not match "'apple'"

You can also use this in a with statement.

>>> with assert_raises_regex(TypeError, 'unsupported operand type\(s\)'):
... 1 + {}
>>> with assert_raises_regex(TypeError, 'banana'):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ markers =
slow: mark a test as slow
network: mark a test as network
high_memory: mark a test as a high-memory only
doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
addopts = --strict-data-files
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL