Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ada765b

Browse files
committed
Make optional in docstrings optional
1 parent d197f42 commit ada765b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,19 +350,19 @@ An example docstring looks like:
350350
Respective beginning and end of each line. If scalars are
351351
provided, all lines will have the same length.
352352
353-
colors : array-like of colors, optional, default: 'k'
353+
colors : array-like of colors, default: 'k'
354354
355-
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, optional
355+
linestyles : {'solid', 'dashed', 'dashdot', 'dotted'}, default: 'solid'
356356
357-
label : string, optional, default: ''
357+
label : str, default: ''
358358
359359
Returns
360360
-------
361361
lines : `~matplotlib.collections.LineCollection`
362362
363363
Other Parameters
364364
----------------
365-
**kwargs : `~matplotlib.collections.LineCollection` properties.
365+
**kwargs : `~matplotlib.collections.LineCollection` properties
366366
367367
See also
368368
--------
@@ -420,9 +420,19 @@ precisely in the text.
420420
Generally, the `numpydoc docstring guide`_ conventions apply. The following
421421
rules expand on them where the numpydoc conventions are not specific.
422422

423+
As opposed to the numpydoc guide, parameters need not be marked as
424+
*optional* if they have a simple default. This removes unnecessary clutter.
425+
The optional aspect is already clear from the presence of a default value.
426+
More specifically
427+
428+
- use `{name} : {type}, default: {val}` when possible.
429+
- use `{name} : {type}, optional` and describe the default in the text if
430+
in cannot be explained sufficiently in the above way.
431+
423432
Use ``float`` for a type that can be any number.
424433

425-
Use ``(float, float)`` to describe a 2D position.
434+
Use ``(float, float)`` to describe a 2D position. The parentheses should be
435+
included to make the tuple-ness more obvious.
426436

427437
Use ``array-like`` for homogeneous numeric sequences, which could
428438
typically be a numpy.array. Dimensionality may be specified using ``2D``,
@@ -460,7 +470,7 @@ Use abbreviated links ```.Normalize``` in the text.
460470

461471
.. code-block:: rst
462472
463-
norm : `~matplotlib.colors.Normalize`, optional
473+
norm : `~matplotlib.colors.Normalize`
464474
A `.Normalize` instance is used to scale luminance data to 0, 1.
465475
466476
``See also`` sections

0 commit comments

Comments
 (0)