Skip to content

Commit

Permalink
DOC fix autodocs when optional dependencies are not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Nov 14, 2016
1 parent 980f3ab commit 5056336
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/source/api/sklearn_crfsuite.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
eli5.sklearn_crfsuite
=====================

.. automodule:: eli5.sklearn_crfsuite
.. automodule:: eli5.sklearn_crfsuite.explain_weights
:members:

24 changes: 23 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,29 @@
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('..'))


from unittest.mock import MagicMock

class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
if name == '_mock_methods':
raise AttributeError()
return Mock()


MOCK_MODULES = [
'lightning',
'lightning.impl',
'lightning.impl.base',
'sklearn_crfsuite',
'IPython',
'IPython.display',
]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)


# -- General configuration ------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions eli5/sklearn_crfsuite/explain_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def explain_weights_sklearn_crfsuite(crf,
target_names=None,
target_order=None,
feature_re=None):
""" Explain sklearn_crfsuite.CRF weights """
feature_names = np.array(crf.attributes_)
state_coef = crf_state_coef(crf).todense().A
transition_coef = crf_transition_coef(crf)
Expand Down

0 comments on commit 5056336

Please sign in to comment.