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

Fix Sphinx warnings #1442

Merged
merged 12 commits into from
Jul 5, 2017
Merged

Fix Sphinx warnings #1442

merged 12 commits into from
Jul 5, 2017

Conversation

prerna135
Copy link
Contributor

@prerna135 prerna135 commented Jun 22, 2017

There are many warnings when generating the Sphinx documentation for gensim, see #1192 .

The issues are due to badly formatted .rst markup, paper citations, indentation etc. This PR fixes them.

Fixes warnings in the .py files
@menshikh-iv
Copy link
Contributor

@prerna135 Travis broken because flake8 detect some issues like W293 blank line contains whitespace and W291 trailing whitespace, you can see flake8 log at the end of travis log

@@ -113,16 +113,18 @@ class CoherenceModel(interfaces.TransformationABC):
def __init__(self, model=None, topics=None, texts=None, corpus=None, dictionary=None,
window_size=None, coherence='c_v', topn=10, processes=-1):
"""
Args:
Copy link
Owner

@piskvorky piskvorky Jun 23, 2017

Choose a reason for hiding this comment

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

Why this change? We're trying to use the Google Code Style consistently, let's stick to that :) CC @menshikh-iv

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It gave an unexpected section title and expected indentation warning during make clean html. And it seemed like the reST Sphinx format was being followed, according to which a keyword followed by a colon followed by some text is a description list. And an underlined keyword is a section title. Also, text in a description list should be indented.

Copy link
Contributor

Choose a reason for hiding this comment

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

@prerna135 Please look at the example and check that plugin works correctly (napoleon ext for sphinx)

@menshikh-iv Fixing warnings in the .py files according to the Google Code Style. Most of the warnings were due to indentation errors.
@piskvorky
Copy link
Owner

Awesome! These sphinx errors have been a pain in the butt for a long time, thanks @prerna135 :)

@menshikh-iv
Copy link
Contributor

Let's continue:+1:

Before: build succeeded, 132 warnings.
After: build succeeded, 45 warnings.

build succeeded, 21 warnings.
Getting there. :-)
@prerna135
Copy link
Contributor Author

@menshikh-iv This is with reference to the above commit. It's weird that the Travis build fails since the doc2vec and word2vec files were not modified at all. They were just renamed from .rst to .inc to remove the duplicate citation errors. Any idea as to why this happened?

@chinmayapancholi13
Copy link
Contributor

@prerna135 It seems like the tests are failing due to unwanted flake8 checks being done for .inc files. You can add .inc files to flake8 ignore list as done in #1309.

Now I'm down to,
`build succeeded, 5 warnings.`

However, I'm in a bit of a fix. Changing `doc2vec.rst` and `word2vec.rst` to `.inc` files removed the duplicate warnings but it also invalidates the references to these documents from my main toctree and the following warnings are produced.

`apiref.rst:8: WARNING: toctree contains reference to nonexisting document u'models/doc2vec'`
`apiref.rst:8: WARNING: toctree contains reference to nonexisting document u'models/word2vec'`
@prerna135
Copy link
Contributor Author

ping @menshikh-iv

@menshikh-iv
Copy link
Contributor

Good job @prerna135: build succeeded, 21 warnings., remaining errors

/home/ivan/release/test/gensim/docs/src/apiref.rst:8: WARNING: toctree contains reference to nonexisting document u'models/word2vec'
/home/ivan/release/test/gensim/docs/src/apiref.rst:8: WARNING: toctree contains reference to nonexisting document u'models/doc2vec'
WARNING: The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:
 https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

WARNING: CUDA is installed, but device gpu is not available  (error: Unable to get the number of gpus available: unknown error)
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/coherencemodel.py:docstring of gensim.models.coherencemodel.CoherenceModel:59: WARNING: Unexpected indentation.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/ldaseqmodel.py:docstring of gensim.models.ldaseqmodel.sslm.compute_post_variance:8: WARNING: Literal block ends without a blank line; unexpected unindent.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/ldaseqmodel.py:docstring of gensim.models.ldaseqmodel.sslm.compute_post_variance:13: WARNING: Literal block ends without a blank line; unexpected unindent.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/dtmmodel.py:docstring of gensim.models.wrappers.dtmmodel:9: WARNING: Footnote [1] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/fasttext.py:docstring of gensim.models.wrappers.fasttext:16: WARNING: Footnote [1] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/varembed.py:docstring of gensim.models.wrappers.varembed:8: WARNING: Footnote [1] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/varembed.py:docstring of gensim.models.wrappers.varembed:10: WARNING: Footnote [2] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/wordrank.py:docstring of gensim.models.wrappers.wordrank.Wordrank.train:10: WARNING: Unexpected indentation.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/wordrank.py:docstring of gensim.models.wrappers.wordrank.Wordrank.train:13: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/wordrank.py:docstring of gensim.models.wrappers.wordrank:9: WARNING: Footnote [1] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/models/wrappers/wordrank.py:docstring of gensim.models.wrappers.wordrank:10: WARNING: Footnote [2] is not referenced.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/simserver/simserver.py:docstring of simserver.simserver.SimServer:4: WARNING: Literal block expected; none found.
WARNING: /home/ivan/release/test/gensim/docs/src/sklearn_integration/sklearn_wrapper_gensim_ldamodel.rst:4: (WARNING/2) autodoc: failed to import module u'gensim.sklearn_integration.sklearn_wrapper_gensim_ldamodel.SklearnWrapperLdaModel'; the following exception was raised:
Traceback (most recent call last):
  File "/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 657, in import_object
    __import__(self.modname)
ImportError: No module named SklearnWrapperLdaModel
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/summarization/summarizer.py:docstring of gensim.summarization.summarizer.summarize:13: WARNING: Unexpected indentation.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/topic_coherence/indirect_confirmation_measure.py:docstring of gensim.topic_coherence.indirect_confirmation_measure.cosine_similarity:5: WARNING: Unexpected indentation.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/topic_coherence/indirect_confirmation_measure.py:docstring of gensim.topic_coherence.indirect_confirmation_measure.cosine_similarity:6: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/ivan/.virtualenvs/dd/local/lib/python2.7/site-packages/gensim/topic_coherence/indirect_confirmation_measure.py:docstring of gensim.topic_coherence.indirect_confirmation_measure.cosine_similarity:8: WARNING: Unexpected indentation.

let's continue, you're almost done 👍

@prerna135
Copy link
Contributor Author

@menshikh-iv Only 1 unfathomable warning left! I can't, for the life of me, seem to figure out where this indentation error is! There seems to be some sort of problem with the mathematical formula for cosine_similarity in indirect_confirmation_measure.py, because the warning disappears as soon as I remove it. Here's a copy of the output from the make clean html

rm -rf _build/*
sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.6.3
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 82 source files that are out of date
updating environment: 82 added, 0 changed, 0 removed
'pattern' package not found; tag filters are not available for English                                                                                                                           
Could not import Theano, will use standard float for default ShardedCorpus dtype.                                                                                                                
/Users/prerna135/Documents/GitHub/gensim/gensim_env/lib/python2.7/site-packages/sklearn/utils/__init__.py:10: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from .murmurhash import murmurhash3_32
/Users/prerna135/Documents/GitHub/gensim/gensim_env/lib/python2.7/site-packages/sklearn/utils/__init__.py:10: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192, got 176
  from .murmurhash import murmurhash3_32
reading sources... [100%] wiki                                                                                                                                                                   
/Users/prerna135/Documents/GitHub/gensim/gensim_env/lib/python2.7/site-packages/gensim-2.2.0-py2.7-macosx-10.6-intel.egg/gensim/topic_coherence/indirect_confirmation_measure.py:docstring of gensim.topic_coherence.indirect_confirmation_measure.cosine_similarity:8: WARNING: Block quote ends without a blank line; unexpected unindent.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] wiki                                                                                                                                                                    
generating indices... genindex
writing additional pages... index search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 1 warning.
rm -r _build/html/_sources
cp -r _build/html/* ../

Build finished. The HTML pages are in ../

@menshikh-iv menshikh-iv changed the title Fixes a part of #1192 Fix Sphinx warnings Jul 5, 2017
@menshikh-iv
Copy link
Contributor

menshikh-iv commented Jul 5, 2017

Nice work @prerna135 🥇

@menshikh-iv menshikh-iv mentioned this pull request Jul 5, 2017
@menshikh-iv menshikh-iv merged commit ede6eb2 into piskvorky:develop Jul 5, 2017
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