Skip to content

[MRG+1] DOC A few fixes in the docstrings of all classifiers. - #4004

Closed
raghavrv wants to merge 1 commit into
scikit-learn:masterfrom
raghavrv:doc_fix_passive_aggressive
Closed

raghavrv wants to merge 1 commit into
scikit-learn:masterfrom
raghavrv:doc_fix_passive_aggressive

Conversation

@raghavrv

Copy link
Copy Markdown
Member
  • Make the multiple lines in docstring appear without any extra spaces in between the two words where multilines are separated by \ at the end of 1st line.

docstring
Before :

    coef_ : array, shape = [1, n_features] if n_classes == 2 else [n_classes,            n_features]

After :

    coef_ : array, shape = [1, n_features] if n_classes == 2 else [n_classes, n_features]

html
No change

  • Refactor a few multiline imports to make them look neater.

A very minor PR, @jnothman could you take a look...

@raghavrv raghavrv changed the title COSMIT Minor fix in passive aggressive docstring [MRG] COSMIT Minor fix in passive aggressive docstring Dec 25, 2014
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 51f40b0 on ragv:doc_fix_passive_aggressive into d65d8c4 on scikit-learn:master.

@jnothman

Copy link
Copy Markdown
Member

It also needs to display correctly in the generated HTML docs (install sphinx and matplotlib and run make doc-noplot to check). As it is, I think it needs a word like "or" or "else" in there to make the HTML docs reasonably.

@raghavrv raghavrv changed the title [MRG] COSMIT Minor fix in passive aggressive docstring [WIP] COSMIT Minor fix in passive aggressive docstring Dec 26, 2014
@raghavrv

Copy link
Copy Markdown
Member Author

The HTML docs seem to look good... and also most other classifiers have docstring defined this way....

Would you mind checking the docstrings for a few classifiers like SGDClassifier, PassiveAggressiveClassifier etc... using both help(SGDClassifier) as well as print SGDClassifier.__doc__.

I am wondering if this issue is localized to my shell...

Sorry for troubling you :p

@raghavrv raghavrv changed the title [WIP] COSMIT Minor fix in passive aggressive docstring [WIP] COSMIT A few fixes in the docstrings of all classifiers. Dec 26, 2014
@raghavrv

Copy link
Copy Markdown
Member Author

This seems to exist wherever \ was used at the end of the line...

I tried displaying the docstring with ipython notebook and got similar results...

image

@raghavrv

Copy link
Copy Markdown
Member Author

Could I expand this PR to correct all such docstrings?

@jnothman

Copy link
Copy Markdown
Member

I'm not surprised that \ didn't work as intended.

But all I meant by my previous comment was that the geography wasn't going to be visible in HTML, so "or" or "else" is necessary.

But sure, widen the scope.

@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch from 51f40b0 to b9cb829 Compare December 27, 2014 14:38
@raghavrv raghavrv changed the title [WIP] COSMIT A few fixes in the docstrings of all classifiers. [MRG] COSMIT A few fixes in the docstrings of all classifiers. Dec 27, 2014
@raghavrv raghavrv changed the title [MRG] COSMIT A few fixes in the docstrings of all classifiers. [MRG] DOC A few fixes in the docstrings of all classifiers. Dec 27, 2014
@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch 3 times, most recently from ef3a10f to d94f2a3 Compare December 27, 2014 15:26
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling d94f2a3 on ragv:doc_fix_passive_aggressive into 8e3f21d on scikit-learn:master.

@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch 3 times, most recently from 869205f to 463f47c Compare December 27, 2014 17:22
@amueller

Copy link
Copy Markdown
Member

Have you checked whether shpinx threw any additional "column span alignment" errors after your changes?

@raghavrv

Copy link
Copy Markdown
Member Author

Yea :)

The diff between the outputs of make doc-noplot with this branch ( doc_fix_passive_aggressive ) and the master did not contain any error / warning...

@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch from 463f47c to ef8681f Compare December 28, 2014 10:40
Comment thread sklearn/svm/classes.py

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is there a doc test that automatically reports error for this kind of typo?

( The previous, under sphinx had made the entire line appear in bold like shown highlighted here )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there is no test for this, but it should result in a sphinx error. I'm not sure how many sphinx errors we currently have (it frequently gets very bad) and if it is visible at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

More broadly, we need to merge our numpydoc back into the numpydoc project, and add fixes there...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note they've spun it off as a separate project/pypi package, so it should be here as a dependency or marked as external.

@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch 4 times, most recently from 6df77ae to cd57944 Compare January 1, 2015 23:22
@raghavrv
raghavrv force-pushed the doc_fix_passive_aggressive branch from cd57944 to 0e94ba5 Compare January 4, 2015 10:46
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.0%) when pulling 0e94ba5 on ragv:doc_fix_passive_aggressive into e98c513 on scikit-learn:master.

@raghavrv

raghavrv commented Jan 4, 2015

Copy link
Copy Markdown
Member Author

@jnothman @amueller Anything else to be done for this PR?

@amueller

amueller commented Jan 5, 2015

Copy link
Copy Markdown
Member

I am pretty certain that I introduced some of the backslashes for column span alignment errors, so it would be good to double check that removing them will not introduce them again. So you said you did a diff on the log of make doc? did you clean the doc folder in between?

@raghavrv

raghavrv commented Jan 5, 2015

Copy link
Copy Markdown
Member Author

Oh... I don't think I did that... I'll try cleaning the doc folder in between and let you know the results...

@raghavrv

raghavrv commented Jan 5, 2015

Copy link
Copy Markdown
Member Author

Yea I did that... and this diff file seemed to not have any of the "column, span, alignment or error" words in it... (except for span / error words in the file name)...

I guess its good then?

@amueller

amueller commented Jan 5, 2015

Copy link
Copy Markdown
Member

Seems good. +1 then.

@raghavrv

raghavrv commented Jan 5, 2015

Copy link
Copy Markdown
Member Author

Thanks :)

@raghavrv raghavrv changed the title [MRG] DOC A few fixes in the docstrings of all classifiers. [MRG+1] DOC A few fixes in the docstrings of all classifiers. Jan 5, 2015

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I frankly dislike this outdenting in the source code, which is at least as important as help output. I'd rather investigate whether numpydoc has a mechanism for handling oversize parameter type descriptions, and if not, proposing one at the numpydoc project (and again, working towards merging the divergent implementation in scikit-learn).

@raghavrv

raghavrv commented Jan 8, 2015

Copy link
Copy Markdown
Member Author

@jnothman in general this pr is all about converting indented backslash-ed extension of previous line to outdented form...

    Parameters
    ----------
    foo : a really really long line \
    Extension of previous line

To

    Parameters
    ----------
    foo : a really really long line \
Extension of previous line

Such that it is displayed in the docstring correctly... ( both were being rendered by sphinx correctly )

I agree with the fact that it does make the code look ugly... Please advice me on how I should proceed with this pr.... :)

@jnothman

jnothman commented Jan 8, 2015

Copy link
Copy Markdown
Member

I agree with the fact that it does make the code look ugly... Please advice me on how I should proceed with this pr.... :)

Seeing as no solution we've found by simply modifying the docstring has satisfied all targets...: Create an issue to document the problem, and try and solve it the right way. If it's an issue of how to represent these things and how that gets processed into sphinx code, fix it there.

@raghavrv

raghavrv commented Jan 8, 2015

Copy link
Copy Markdown
Member Author

Hmm thanks... I'll close this now?

@raghavrv raghavrv closed this Jan 8, 2015
@jnothman

jnothman commented Jan 8, 2015

Copy link
Copy Markdown
Member

Thanks for your effort on this in any case!

@raghavrv

raghavrv commented Jan 8, 2015

Copy link
Copy Markdown
Member Author

This I feel can be fixed by making the below :

    Parameters :
    ----------
    foo : a really really long line
    Extension of the prev line

To render correctly in sphinx...

@jnothman

jnothman commented Jan 8, 2015

Copy link
Copy Markdown
Member

That may not be a good solution because I think currently something like:

a : a's type
b : b's type

is supported. So then you'd run into ambiguity.

So I'd rather the double-indent for continuation (or the fact that there is more indent before less indent, before back to baseline). The current just takes typespec as the rest of the line; and description as everything between that and the next text at the baseline.

Alternatively, Reader or arg_type could be modified to know about backslash-ending lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants