-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: fix EX02 errors in docstrings #51369
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
DOC: fix EX02 errors in docstrings #51369
Conversation
pandas/_libs/tslibs/timestamps.pyx
Outdated
>>> pd.Timestamp.fromtimestamp(1584199972) | ||
Timestamp('2020-03-14 15:32:52') | ||
Timestamp('2020-03-14 16:32:52') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the exact output here depends on your tz's local time
In [1]: pd.Timestamp.fromtimestamp(1584199972)
Out[1]: Timestamp('2020-03-14 15:32:52')
In [2]: import os
In [3]: os.environ['TZ'] = 'Europe/Brussels'
In [4]: import time
In [5]: time.tzset()
In [6]: pd.Timestamp.fromtimestamp(1584199972)
Out[6]: Timestamp('2020-03-14 16:32:52')
I think this can probably be just removed directly from ci/code_checks.sh
(I presume CI runs in UTC?), or could just doctest skip it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, it was my mistake. I had to read the next line 1457
.
I guess CI runs in UTC, because I get a one-hour difference running validation locally.
Can we leave pandas.Timestamp.fromtimestamp
in ci/code_checks.sh
to ignore this function while validating docstrings and use the original example for UTC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we shoudn't have the excludes
list in ci/code_checks.sh
, the objective is to remove that - I think if you add # doctest skip
(something like that, check other docstrings for the exact syntax) just to this doctest, and keep it removed from ci/code_checks
, that should be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I did as you suggested and updated the PR.
should be good, thanks - if you resolve the conflicts we can get this in |
ci/code_checks.sh
Outdated
pandas.Timestamp.fromtimestamp \ | ||
pandas.Series.sparse.density \ | ||
pandas.Series.sparse.npoints \ | ||
pandas.Series.sparse.sp_values \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intentional? looks like you're adding pandas.Series.sparse.sp_values
to the ignore list - perhaps something didn't go quite right when merging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't intentional. I am not very familiar with resolving merge conflicts.
While I was working on the PR the functions pandas.Series.sparse.density
, pandas.Series.sparse.npoints
, pandas.Series.sparse.sp_values
were in the ignore list. I deleted these functions from the ignore list in my next PR, which has been merged just a couple of hours ago. To resolve the conflict I have to delete these functions now.
I can do it locally and push a new commit. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating - could you run this test locally and check it passes please?
=================================== FAILURES ===================================
________________ test_nat_doc_strings[Timestamp.fromtimestamp] _________________
[gw0] linux -- Python 3.8.16 /home/runner/micromamba/envs/test/bin/python3.8
compare = (<class 'pandas._libs.tslibs.timestamps.Timestamp'>, 'fromtimestamp')
@pytest.mark.parametrize(
"compare",
(
_get_overlap_public_nat_methods(Timestamp, True)
+ _get_overlap_public_nat_methods(Timedelta, True)
),
ids=lambda x: f"{x[0].__name__}.{x[1]}",
)
def test_nat_doc_strings(compare):
# see gh-17327
#
# The docstrings for overlapping methods should match.
klass, method = compare
klass_doc = getattr(klass, method).__doc__
# Ignore differences with Timestamp.isoformat() as they're intentional
if klass == Timestamp and method == "isoformat":
return
if method == "to_numpy":
# GH#44460 can return either dt64 or td64 depending on dtype,
# different docstring is intentional
return
nat_doc = getattr(NaT, method).__doc__
> assert klass_doc == nat_doc
E AssertionError: assert '\n Ti...me.\n ' == '\n Ti...me.\n '
E Skipping 188 identical leading characters in diff, use -v to show
E - 584199972)
E + 584199972) # doctest: +SKIP
E Timestamp('2020-03-14 15:32:52')
E
E Note that the output may change depending on your local time.
pandas/tests/scalar/test_nat.py:325: AssertionError
I've got 1 failure.
|
yeah I think you just need to make the same change to the docstring in pandas/_libs/tslibs/nattype.pyx |
Thank you, I added the change in pandas/_libs/tslibs/nattype.pyx |
…EX02-errors-docstrings-IV
🤔 CI keeps failing with Do you feel like trying to reset to |
Yes, I noticed that too and I have no clue what is the reason.
I agree it might be the best way to deal with the situation. I will push the same changes to a new branch and open a new PR. |
Did you run Looks like it was originally 755
|
looks like we did this one in #51453, so we can close this PR |
Related to the issue #51236
This PR enables functions:
pandas.core.groupby.DataFrameGroupBy.take
pandas.Timestamp.fromtimestamp