Skip to content

Commit e165cb1

Browse files
jmloyolaOriolAbril
andauthored
Fix numpydoc in pm.Data, pm.MutableData, pm.ConstantData (#5485)
* Add space between colon in parameters * Fix link to Model.set_data function in documentation * Fix docstring parameters type * Fix link to example notebook * Add punctuation to parameter description * Move information to extended description * Move parameter description to respect parameters order * Add double ticks for code references in docstrings * Link function in pymc * Add default behaviour of optional parameters * Add reference to pm.Data in pm.ConstantData and pm.MutableData * Update pymc/data.py Co-authored-by: Oriol Abril-Pla <[email protected]> * Use intersphinx for link * Be explicit about pandas types * Improve text of notebook link * Fix docstring Co-authored-by: Oriol Abril-Pla <[email protected]>
1 parent fa0308a commit e165cb1

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

pymc/data.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ def ConstantData(
516516
) -> TensorConstant:
517517
"""Alias for ``pm.Data(..., mutable=False)``.
518518
519-
Registers the ``value`` as a ``TensorConstant`` with the model.
519+
Registers the ``value`` as a :class:`~aesara.tensor.TensorConstant` with the model.
520+
For more information, please reference :class:`pymc.Data`.
520521
"""
521522
return Data(
522523
name,
@@ -538,7 +539,8 @@ def MutableData(
538539
) -> SharedVariable:
539540
"""Alias for ``pm.Data(..., mutable=True)``.
540541
541-
Registers the ``value`` as a ``SharedVariable`` with the model.
542+
Registers the ``value`` as a :class:`~aesara.compile.sharedvalue.SharedVariable`
543+
with the model. For more information, please reference :class:`pymc.Data`.
542544
"""
543545
return Data(
544546
name,
@@ -562,35 +564,46 @@ def Data(
562564
"""Data container that registers a data variable with the model.
563565
564566
Depending on the ``mutable`` setting (default: True), the variable
565-
is registered as a ``SharedVariable``, enabling it to be altered
566-
in value and shape, but NOT in dimensionality using ``pm.set_data()``.
567+
is registered as a :class:`~aesara.compile.sharedvalue.SharedVariable`,
568+
enabling it to be altered in value and shape, but NOT in dimensionality using
569+
:func:`pymc.set_data`.
570+
571+
To set the value of the data container variable, check out
572+
:func:`pymc.Model.set_data`.
573+
574+
For more information, read the notebook :ref:`nb:data_container`.
567575
568576
Parameters
569577
----------
570-
name: str
571-
The name for this variable
572-
value: {List, np.ndarray, pd.Series, pd.Dataframe}
573-
A value to associate with this variable
574-
mutable : bool, optional
575-
Switches between creating a ``SharedVariable`` (``mutable=True``, default)
576-
vs. creating a ``TensorConstant`` (``mutable=False``).
577-
Consider using ``pm.ConstantData`` or ``pm.MutableData`` as less verbose
578-
alternatives to ``pm.Data(..., mutable=...)``.
579-
dims: {str, tuple of str}, optional, default=None
578+
name : str
579+
The name for this variable.
580+
value : array_like or pandas.Series, pandas.Dataframe
581+
A value to associate with this variable.
582+
dims : str or tuple of str, optional
580583
Dimension names of the random variables (as opposed to the shapes of these
581-
random variables). Use this when `value` is a pandas Series or DataFrame. The
582-
`dims` will then be the name of the Series / DataFrame's columns. See ArviZ
584+
random variables). Use this when ``value`` is a pandas Series or DataFrame. The
585+
``dims`` will then be the name of the Series / DataFrame's columns. See ArviZ
583586
documentation for more information about dimensions and coordinates:
584587
:ref:`arviz:quickstart`.
585-
export_index_as_coords: bool, optional, default=False
586-
If True, the `Data` container will try to infer what the coordinates should be
587-
if there is an index in `value`.
588-
**kwargs: dict, optional
588+
If this parameter is not specified, the random variables will not have dimension
589+
names.
590+
export_index_as_coords : bool, default=False
591+
If True, the ``Data`` container will try to infer what the coordinates should be
592+
if there is an index in ``value``.
593+
mutable : bool, optional
594+
Switches between creating a :class:`~aesara.compile.sharedvalue.SharedVariable`
595+
(``mutable=True``) vs. creating a :class:`~aesara.tensor.TensorConstant`
596+
(``mutable=False``).
597+
Consider using :class:`pymc.ConstantData` or :class:`pymc.MutableData` as less
598+
verbose alternatives to ``pm.Data(..., mutable=...)``.
599+
If this parameter is not specified, the value it takes will depend on the
600+
version of the package. Since ``v4.1.0`` the default value is
601+
``mutable=False``, with previous versions having ``mutable=True``.
602+
**kwargs : dict, optional
589603
Extra arguments passed to :func:`aesara.shared`.
590604
591605
Examples
592606
--------
593-
594607
>>> import pymc as pm
595608
>>> import numpy as np
596609
>>> # We generate 10 datasets
@@ -609,12 +622,6 @@ def Data(
609622
... # Switch out the observed dataset
610623
... model.set_data('data', data_vals)
611624
... idatas.append(pm.sample())
612-
613-
To set the value of the data container variable, check out
614-
:func:`pymc.model.set_data()`.
615-
616-
For more information, take a look at this example notebook
617-
https://docs.pymc.io/notebooks/data_container.html
618625
"""
619626
if isinstance(value, list):
620627
value = np.array(value)

0 commit comments

Comments
 (0)