Skip to content

Commit b1d8d4f

Browse files
committed
MNT update the way the documentation is shown
1 parent 82f7ffd commit b1d8d4f

14 files changed

+48
-20
lines changed

doc/_templates/class.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
.. autoclass:: {{ objname }}
77

8-
{% block methods %}
9-
.. automethod:: __init__
10-
{% endblock %}
11-
128
.. include:: {{module}}.{{objname}}.examples
139

1410
.. raw:: html

doc/_templates/numpydoc_docstring.py renamed to doc/_templates/numpydoc_docstring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
{{notes}}
1414
{{references}}
1515
{{examples}}
16-
{{methods}}
16+
{{methods}}

doc/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ Prototype selection
154154
.. autosummary::
155155
:toctree: generated/
156156
:template: function.rst
157-
157+
158158
tensorflow.balanced_batch_generator
159159

160160
.. _misc_ref:
161-
161+
162162
Miscellaneous
163163
=============
164164

doc/conf.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@
5050
extensions.append('sphinx.ext.imgmath')
5151
imgmath_image_format = 'svg'
5252

53-
autodoc_default_flags = ['members', 'inherited-members']
53+
autodoc_default_options = {
54+
"members": True,
55+
"inherited-members": True,
56+
}
5457

5558
# Add any paths that contain templates here, relative to this directory.
5659
templates_path = ['_templates']
@@ -309,6 +312,30 @@
309312
issues_github_path = 'scikit-learn-contrib/imbalanced-learn'
310313
issues_user_uri = 'https://github.com/{user}'
311314

315+
# Hack to get kwargs to appear in docstring #18434
316+
# TODO: Remove when https://github.com/sphinx-doc/sphinx/pull/8234 gets
317+
# merged
318+
from sphinx.util import inspect # noqa
319+
from sphinx.ext.autodoc import ClassDocumenter # noqa
320+
321+
322+
class PatchedClassDocumenter(ClassDocumenter):
323+
def _get_signature(self):
324+
old_signature = inspect.signature
325+
326+
def patch_signature(subject, bound_method=False, follow_wrapped=True):
327+
# changes the default of follow_wrapped to True
328+
return old_signature(
329+
subject,
330+
bound_method=bound_method,
331+
follow_wrapped=follow_wrapped,
332+
)
333+
334+
inspect.signature = patch_signature
335+
result = super()._get_signature()
336+
inspect.signature = old_signature
337+
return result
338+
312339

313340
# Temporary work-around for spacing problem between parameter and parameter
314341
# type in the doc, see https://github.com/numpy/numpydoc/issues/215. The bug
@@ -317,7 +344,8 @@
317344
# In an ideal world, this would get fixed in this PR:
318345
# https://github.com/readthedocs/sphinx_rtd_theme/pull/747/files
319346
def setup(app):
320-
app.add_javascript('js/copybutton.js')
347+
app.registry.documenters["class"] = PatchedClassDocumenter
348+
app.add_javascript("js/copybutton.js")
321349
app.add_stylesheet("basic.css")
322350
# app.connect('autodoc-process-docstring', generate_example_rst)
323351

imblearn/ensemble/_bagging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,17 @@ class BalancedBaggingClassifier(BaggingClassifier):
140140
----------
141141
.. [1] L. Breiman, "Pasting small votes for classification in large
142142
databases and on-line", Machine Learning, 36(1), 85-103, 1999.
143+
143144
.. [2] L. Breiman, "Bagging predictors", Machine Learning, 24(2), 123-140,
144145
1996.
146+
145147
.. [3] T. Ho, "The random subspace method for constructing decision
146148
forests", Pattern Analysis and Machine Intelligence, 20(8), 832-844,
147149
1998.
150+
148151
.. [4] G. Louppe and P. Geurts, "Ensembles on Random Patches", Machine
149152
Learning and Knowledge Discovery in Databases, 346-361, 2012.
153+
150154
.. [5] Chen, Chao, Andy Liaw, and Leo Breiman. "Using random forest to
151155
learn imbalanced data." University of California, Berkeley 110,
152156
2004.

imblearn/over_sampling/_random_over_sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class RandomOverSampler(BaseOverSampler):
3636
3737
Attributes
3838
----------
39-
sample_indices_ : ndarray of shape (n_new_samples)
39+
sample_indices_ : ndarray of shape (n_new_samples,)
4040
Indices of the samples selected.
4141
4242
.. versionadded:: 0.4

imblearn/under_sampling/_prototype_selection/_condensed_nearest_neighbour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CondensedNearestNeighbour(BaseCleaningSampler):
5252
5353
Attributes
5454
----------
55-
sample_indices_ : ndarray of shape (n_new_samples)
55+
sample_indices_ : ndarray of shape (n_new_samples,)
5656
Indices of the samples selected.
5757
5858
.. versionadded:: 0.4

imblearn/under_sampling/_prototype_selection/_edited_nearest_neighbours.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class EditedNearestNeighbours(BaseCleaningSampler):
5656
5757
Attributes
5858
----------
59-
sample_indices_ : ndarray of shape (n_new_samples)
59+
sample_indices_ : ndarray of shape (n_new_samples,)
6060
Indices of the samples selected.
6161
6262
.. versionadded:: 0.4
@@ -199,7 +199,7 @@ class RepeatedEditedNearestNeighbours(BaseCleaningSampler):
199199
200200
Attributes
201201
----------
202-
sample_indices_ : ndarray of shape (n_new_samples)
202+
sample_indices_ : ndarray of shape (n_new_samples,)
203203
Indices of the samples selected.
204204
205205
.. versionadded:: 0.4
@@ -383,7 +383,7 @@ class without early stopping.
383383
384384
Attributes
385385
----------
386-
sample_indices_ : ndarray of shape (n_new_samples)
386+
sample_indices_ : ndarray of shape (n_new_samples,)
387387
Indices of the samples selected.
388388
389389
.. versionadded:: 0.4

imblearn/under_sampling/_prototype_selection/_instance_hardness_threshold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class InstanceHardnessThreshold(BaseUnderSampler):
5757
5858
Attributes
5959
----------
60-
sample_indices_ : ndarray of shape (n_new_samples)
60+
sample_indices_ : ndarray of shape (n_new_samples,)
6161
Indices of the samples selected.
6262
6363
.. versionadded:: 0.4

imblearn/under_sampling/_prototype_selection/_nearmiss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class NearMiss(BaseUnderSampler):
5353
5454
Attributes
5555
----------
56-
sample_indices_ : ndarray of shape (n_new_samples)
56+
sample_indices_ : ndarray of shape (n_new_samples,)
5757
Indices of the samples selected.
5858
5959
.. versionadded:: 0.4

0 commit comments

Comments
 (0)