Skip to content

DOC: correct examples for "is_iterator" #31295

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
pytest -q --doctest-modules pandas/core/arrays/boolean.py
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Doctests dtypes/inference.py' ; echo $MSG
pytest -q --doctest-modules pandas/core/dtypes/inference.py -k "is_iterator"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think need to special case these - is doctest maybe just not being run?

Copy link
Member Author

@ShaharNaveh ShaharNaveh Jan 25, 2020

Choose a reason for hiding this comment

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

Doctests are being run, but only for specific files (and for some only for specific functions/methods).

https://github.com/pandas-dev/pandas/blob/2170f4e49bdd6e7bb0441f142fce9528c0c6c422/ci/code_checks.sh#L261-#L310

(Most recent version at the time of writing this)

Those are the only ones who are currently being tested.

RET=$(($RET + $?)) ; echo $MSG "DONE"

fi

### DOCSTRINGS ###
Expand Down
7 changes: 3 additions & 4 deletions pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,20 @@ def is_iterator(obj) -> bool:

Returns
-------
is_iter : bool
bool
Whether `obj` is an iterator.

Examples
--------
>>> is_iterator([1, 2, 3])
>>> is_iterator((x for x in [1, 2, 3]))
True
>>> is_iterator(datetime(2017, 1, 1))
>>> is_iterator([1, 2, 3])
False
>>> is_iterator("foo")
False
>>> is_iterator(1)
False
"""

if not hasattr(obj, "__iter__"):
return False

Expand Down