Optuna: `experimental` decorator adds extra indents to docs

Created on 7 May 2020  路  3Comments  路  Source: optuna/optuna

An extra indent appears in the docs when the experimental decorator is added to a method of a class. This does not happen with a top level (i.e., not nested) class or function.

Steps to reproduce

  1. add an experimental decorator to a method of a class
  2. make the document

Reproducible examples

The following figure shows the docs of Study.enqueue_trial. An extra indent appears after the second paragraph.

image

Expected behavior

no extra indent is shown after the second paragraph

For example, the docs of Study.get_trials, which does not have the experimental decorator, appears as expected.

image

The following figure shows another example. The docs of the train function of LightGBMTuner has no extra indent. Although the function has an experimental decorator, it belongs to the top level classes.

image

bug contribution-welcome

Most helpful comment

@g-votte
Can I work on this?

All 3 comments

It seems we need to indent the .. note:: block when decorating a class method.

>>> print(Study.enqueue_trial.__doc__)
Enqueue a trial with given parameter values.

        You can fix the next sampling parameters which will be evaluated in your
        objective function.

        Example:

            .. testcode::

                import optuna

                def objective(trial):
                    x = trial.suggest_uniform('x', 0, 10)
                    return x ** 2

                study = optuna.create_study()
                study.enqueue_trial({'x': 5})
                study.enqueue_trial({'x': 0})
                study.optimize(objective, n_trials=2)

                assert study.trials[0].params == {'x': 5}
                assert study.trials[1].params == {'x': 0}

        Args:
            params:
                Parameter values to pass your objective function.


    .. note::
        Added in v1.2.0 as an experimental feature. The interface may change in newer versions
        without prior notice. See https://github.com/optuna/optuna/releases/tag/v1.2.0.

>>> print(lightgbm_tuner.train.__doc__)
Wrapper of LightGBM Training API to tune hyperparameters.

    It tunes important hyperparameters (e.g., `min_child_samples` and `feature_fraction`) in a
    stepwise manner. Arguments and keyword arguments for `lightgbm.train()
    <https://lightgbm.readthedocs.io/en/latest/pythonapi/lightgbm.train.html>`_ can be passed.


    .. note::
        Added in v0.18.0 as an experimental feature. The interface may change in newer versions
        without prior notice. See https://github.com/optuna/optuna/releases/tag/v0.18.0.

@g-votte
Can I work on this?

@harupy
Sure! Please go for it!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dwiel picture dwiel  路  4Comments

himkt picture himkt  路  4Comments

superluminance picture superluminance  路  4Comments

ChenjunZou picture ChenjunZou  路  4Comments

dankal444 picture dankal444  路  3Comments