Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT Adjust tests for numpydoc 1.2 #22287

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 12 commits into from
Feb 11, 2022

Conversation

thomasjpfan
Copy link
Member

Reference Issues/PRs

Follow up to #22286

What does this implement/fix? Explain your changes.

The big change is how numpydoc will not parse sections if the number of characters underlining the subsection is incorrect.

Any other comments?

CC @ogrisel

@thomasjpfan thomasjpfan marked this pull request as draft January 24, 2022 20:12
@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jan 24, 2022

I need a tinker with this PR a little more before it is ready for review.

@thomasjpfan thomasjpfan marked this pull request as ready for review January 24, 2022 20:36
@@ -546,8 +536,6 @@ def test_check_docstring_parameters(mock_meta):
"was no space between the param name and colon ('a: int')",
"sklearn.utils.tests.test_testing.f_check_param_definition There "
"was no space between the param name and colon ('b:')",
"sklearn.utils.tests.test_testing.f_check_param_definition "
"Parameter 'c :' has an empty type spec. Remove the colon",
Copy link
Member Author

Choose a reason for hiding this comment

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

In numpydoc 1.2, the c : is now parsed into c + empty type spec.

Comment on lines 605 to 608
"potentially wrong underline length... ",
"Parameters ",
"--------- in ",
"This is available only if delegate has predict_proba.",
Copy link
Member Author

Choose a reason for hiding this comment

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

This it the new error message, when the Parameters header does not have the correct underline length.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I need a ticker with this PR a little more before it is ready for review.

I read that too late. Here is some feedback.

@glemaitre
Copy link
Member

I need a ticker with this PR a little more before it is ready for review.

I did not review but we were discussing yesterday with @ogrisel to maybe make the tests more general to not be caught in the same string matching later on.

@thomasjpfan
Copy link
Member Author

thomasjpfan commented Jan 25, 2022

I did not review but we were discussing yesterday with @ogrisel to maybe make the tests more general to not be caught in the same string matching later on.

The test is checking the strings we are creating:

for i in range(min(len(param_docs), len(param_signature))):
if param_signature[i] != param_docs[i]:
message += [
"There's a parameter name mismatch in function"
" docstring w.r.t. function signature, at index %s"
" diff: %r != %r" % (i, param_signature[i], param_docs[i])
]
break

The reason our tests started to fail is that numpydoc changed its parsing behavior with incorrect underline of sections. This lead to different errors from numpydoc, which caused our string generation to not match up.

PR is ready for review.

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -495,7 +495,7 @@ def score(self, X):
"""This is available only if delegate has score.

Parameters
---------
----------
y : ndarray
Parameter y
"""
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 we need a new test method with a bad underline formatting to cover the new warning/exception handling logic (while still covering the originally intended test cases).

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@thomasjpfan thomasjpfan Jan 27, 2022

Choose a reason for hiding this comment

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

I reverted this change and updating the assert with the new error message

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM assuming CI passes after the latest changes.

@glemaitre glemaitre merged commit 30c8928 into scikit-learn:main Feb 11, 2022
@glemaitre
Copy link
Member

Thanks @thomasjpfan

thomasjpfan added a commit to thomasjpfan/scikit-learn that referenced this pull request Mar 1, 2022
Co-authored-by: Julien Jerphanion <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants