Skip to content
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: Validate that See Also section items do not contain the pandas. prefix #23145

Merged
merged 9 commits into from
Oct 27, 2018

Conversation

thoo
Copy link
Contributor

@thoo thoo commented Oct 14, 2018

Fix #23136
Please also see similar PR #23143

@codecov
Copy link

codecov bot commented Oct 14, 2018

Codecov Report

Merging #23145 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #23145   +/-   ##
=======================================
  Coverage   92.22%   92.22%           
=======================================
  Files         169      169           
  Lines       51261    51261           
=======================================
  Hits        47277    47277           
  Misses       3984     3984
Flag Coverage Δ
#multiple 90.66% <ø> (ø) ⬆️
#single 42.23% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f662c5f...0461c99. Read the comment docs.

@getschomp
Copy link
Contributor

The one I posted is a slightly different issue also affecting the 'See Also' section.(23135/23136) I think you may have missed pushing a commit somehow, because I'm only seeing the blank line changes.

@pep8speaks
Copy link

pep8speaks commented Oct 14, 2018

Hello @thoo! Thanks for updating the PR.

Comment last updated on October 15, 2018 at 17:29 Hours UTC

@thoo
Copy link
Contributor Author

thoo commented Oct 14, 2018

@getschomp Thanks. I just updated.

@datapythonista datapythonista changed the title Warning on Prefix pandas DOC: Validate that See Also section items do not contain the pandas. prefix Oct 14, 2018
@datapythonista datapythonista added Docs CI Continuous Integration labels Oct 14, 2018
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Good start, added some comments, still some things to be fixed.

@@ -499,7 +499,8 @@ def validate_one(func_name):
if not rel_desc:
errs.append('Missing description for '
'See Also "{}" reference'.format(rel_name))

if rel_name[:7].lower() == 'pandas.':
Copy link
Member

Choose a reason for hiding this comment

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

I think it's more pythonic to write if rel_name.startwith('pandas.'): (or you could do the .lower() before the startswith() but I don't think it's needed here.

@@ -499,7 +499,8 @@ def validate_one(func_name):
if not rel_desc:
errs.append('Missing description for '
'See Also "{}" reference'.format(rel_name))

if rel_name[:7].lower() == 'pandas.':
errs.append('{} should not have prefix `pandas`'.format(rel_name))
Copy link
Member

Choose a reason for hiding this comment

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

I think the error message is good, but it'd be even more explicit to say something like 'pandas.DataFrame.head' in the 'See Also' section does not need the 'pandas' prefix, use 'DataFrame.head' instead. What do you think?

The PEP8 validation reported a line > 80 characters, I guess is this one.

@@ -334,6 +334,14 @@ def method(self, foo=None, bar=None):
pass


class BadSeeAlso(object):
Copy link
Member

Choose a reason for hiding this comment

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

Can you place the test classes in the same order as the sections in the docstring (summaries, parameters, returns, see also...)

def prefix_pandas(self):
"""
Return prefix with `pandas` from See Also sec
"""
Copy link
Member

Choose a reason for hiding this comment

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

What's bad in this test? It doesn't have the See Also section, so the new error will not be raised here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@datapythonista Can I get more hints ? :). I wasn't sure what I was doing in the test section. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

it's difficult to explain unit testing in a github comment, but the idea of a unit test is that you want to check that things work automatically. I guess after implementing the error for the pandas prefix, you run the program for a docstring with the prefix, and saw that the error was correctly reported. You need to do the same here, but with code. Most of the stuff is already build, the main thing to do is to write a docstring that should generate the error (this is what goes in this part of the code). And then a program runs the validate_docstrings.py, and makes sure that the error is generated. This is already implemented if you add the method with the docstring you want to validate, and the expected message in the @pytest.mark.parametrize you updated.

@@ -564,6 +572,9 @@ def test_bad_generic_functions(self, func):
assert errors

@pytest.mark.parametrize("klass,func,msgs", [
#SeeAlso tests
Copy link
Member

Choose a reason for hiding this comment

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

There are missing spaces here, including after the # which is a formatting error.

@thoo
Copy link
Contributor Author

thoo commented Oct 14, 2018

Thanks. I will work on them.

Copy link
Contributor Author

@thoo thoo left a comment

Choose a reason for hiding this comment

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

@datapythonista Could you please take a look? Hope everything is resolved.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Looking better, added some comments.

@@ -1234,25 +1234,19 @@ The `method` argument within `DataFrame.corr` can accept a callable in addition
n = len(x)
a = np.zeros(shape=(n, n))
b = np.zeros(shape=(n, n))

Copy link
Member

Choose a reason for hiding this comment

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

can you make sure this file does not appear in the Files changes diff. The cookbook should be untouched in this PR.


See Also
--------
pandas.Series.rename : Alter Series index labels or name
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a period at he end? This is required in the see also description, and this test should only have wrong the pandas. prefix.

Can you add another item, but without the pandas prefix, so we see that when there is more than one item the reported one is the wrong one.


def prefix_pandas(self):
"""
Return prefix with `pandas` from See Also sec
Copy link
Member

Choose a reason for hiding this comment

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

Can you briefly describe the test here. It'll be more useful than this sentence (see other tests for reference). Also, make sure there are no two spaces together, and that the text finishes with a period.

@@ -600,7 +613,10 @@ def test_bad_generic_functions(self, func):
pytest.param('BadReturns', 'no_description', ('foo',),
marks=pytest.mark.xfail),
pytest.param('BadReturns', 'no_punctuation', ('foo',),
marks=pytest.mark.xfail)
marks=pytest.mark.xfail),
# SeeAlso tests
Copy link
Member

Choose a reason for hiding this comment

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

missing space between See Also

marks=pytest.mark.xfail),
# SeeAlso tests
('BadSeeAlso', 'prefix_pandas',
('section does not need `pandas` prefix',)),
Copy link
Member

Choose a reason for hiding this comment

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

can you check for the whole message. It's useful to see what's the exact error reported, and that the item being reported is indeed the one with the prefix.

@thoo thoo force-pushed the Warning_prefix_pandas branch from bcb33b8 to 6e7ab2a Compare October 15, 2018 15:46
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

not sure if one of the lines is more than 80 characters, but if the CI is green, lgtm.

@WillAyd do you want to take a look?

if rel_name.startswith('pandas.'):
errs.append('{} in `See Also` section does not '
'need `pandas` prefix, use {} instead.'
.format(rel_name, rel_name.replace('pandas.', '')))
Copy link
Member

@datapythonista datapythonista Oct 24, 2018

Choose a reason for hiding this comment

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

I'd use rel_name[len('pandas.'):] instead of the replace. I don't think in practice will make a difference, but in a case like pandas.somemod.pandas.MyClass the replace wouldn't work as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I will update it right away.

@thoo thoo force-pushed the Warning_prefix_pandas branch from 6a0d30a to 67ed7f4 Compare October 24, 2018 16:47
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@datapythonista
Copy link
Member

datapythonista commented Oct 25, 2018

Can you check the azure error, and make sure it's green, so we can merge?

@thoo
Copy link
Contributor Author

thoo commented Oct 26, 2018

Can you check the azure error, and make sure it's green, so we can merge?

The error is from miniconda package.

2018-10-24T17:02:31.2718145Z C:\Miniconda\envs\pandas\lib\site-packages\matplotlib\colorbar.py:28: in <module>
2018-10-24T17:02:31.2718445Z     import matplotlib.artist as martist
2018-10-24T17:02:31.2719232Z E   AttributeError: module 'matplotlib' has no attribute 'artist'
2018-10-24T17:02:31.4445103Z ##[error]Cmd.exe exited with code '4'.

thoo added 2 commits October 26, 2018 23:47
…ndas

* repo_org/master: (23 commits)
  DOC: Add docstring validations for "See Also" section (pandas-dev#23143)
  TST: Fix test assertion (pandas-dev#23357)
  BUG: Handle Period in combine (pandas-dev#23350)
  REF: SparseArray imports (pandas-dev#23329)
  CI: Migrate some CircleCI jobs to Azure (pandas-dev#22992)
  DOC: update the is_month_start/is_month_end docstring (pandas-dev#23051)
  Partialy fix issue pandas-dev#23334 - isort pandas/core/groupby directory (pandas-dev#23341)
  TST: Add base test for extensionarray setitem pandas-dev#23300 (pandas-dev#23304)
  API: Add sparse Acessor (pandas-dev#23183)
  PERF: speed up CategoricalIndex.get_loc (pandas-dev#23235)
  fix and test incorrect case in delta_to_nanoseconds (pandas-dev#23302)
  BUG: Handle Datetimelike data in DataFrame.combine (pandas-dev#23317)
  TST: re-enable gbq tests (pandas-dev#23303)
  Switched references of App veyor to azure pipelines in the contributing CI section (pandas-dev#23311)
  isort imports-io (pandas-dev#23332)
  DOC: Added a Multi Index example for the Series.sum method (pandas-dev#23279)
  REF: Make PeriodArray an ExtensionArray (pandas-dev#22862)
  DOC: Added Examples for Series max (pandas-dev#23298)
  API/ENH: tz_localize handling of nonexistent times: rename keyword + add shift option (pandas-dev#22644)
  BUG: Let MultiIndex.set_levels accept any iterable (pandas-dev#23273) (pandas-dev#23291)
  ...
@datapythonista
Copy link
Member

@WillAyd, can you take a look and merge if you're happy?

@WillAyd WillAyd merged commit da9d851 into pandas-dev:master Oct 27, 2018
@WillAyd
Copy link
Member

WillAyd commented Oct 27, 2018

Thanks @thoo

thoo added a commit to thoo/pandas that referenced this pull request Oct 27, 2018
…xamples

* repo_org/master:
  DOC: Validate that See Also section items do not contain the pandas. prefix (pandas-dev#23145)
  API/TST: make hasnans always return python booleans (pandas-dev#23349)
tm9k1 pushed a commit to tm9k1/pandas that referenced this pull request Nov 19, 2018
@thoo thoo deleted the Warning_prefix_pandas branch January 2, 2019 20:26
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants