Skip to content

Fix numpydoc in pm.Data, pm.MutableData, pm.ConstantData #5485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions pymc/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ def ConstantData(
) -> TensorConstant:
"""Alias for ``pm.Data(..., mutable=False)``.

Registers the ``value`` as a ``TensorConstant`` with the model.
Registers the ``value`` as a :class:`~aesara.tensor.TensorConstant` with the model.
For more information, please reference :class:`pymc.Data`.
"""
return Data(
name,
Expand All @@ -538,7 +539,8 @@ def MutableData(
) -> SharedVariable:
"""Alias for ``pm.Data(..., mutable=True)``.

Registers the ``value`` as a ``SharedVariable`` with the model.
Registers the ``value`` as a :class:`~aesara.compile.sharedvalue.SharedVariable`
with the model. For more information, please reference :class:`pymc.Data`.
"""
return Data(
name,
Expand All @@ -562,35 +564,46 @@ def Data(
"""Data container that registers a data variable with the model.

Depending on the ``mutable`` setting (default: True), the variable
is registered as a ``SharedVariable``, enabling it to be altered
in value and shape, but NOT in dimensionality using ``pm.set_data()``.
is registered as a :class:`~aesara.compile.sharedvalue.SharedVariable`,
enabling it to be altered in value and shape, but NOT in dimensionality using
:func:`pymc.set_data`.

To set the value of the data container variable, check out
:func:`pymc.Model.set_data`.

For more information, read the notebook :ref:`nb:data_container`.

Parameters
----------
name: str
The name for this variable
value: {List, np.ndarray, pd.Series, pd.Dataframe}
A value to associate with this variable
mutable : bool, optional
Switches between creating a ``SharedVariable`` (``mutable=True``, default)
vs. creating a ``TensorConstant`` (``mutable=False``).
Consider using ``pm.ConstantData`` or ``pm.MutableData`` as less verbose
alternatives to ``pm.Data(..., mutable=...)``.
dims: {str, tuple of str}, optional, default=None
name : str
The name for this variable.
value : array_like or pandas.Series, pandas.Dataframe
A value to associate with this variable.
dims : str or tuple of str, optional
Dimension names of the random variables (as opposed to the shapes of these
random variables). Use this when `value` is a pandas Series or DataFrame. The
`dims` will then be the name of the Series / DataFrame's columns. See ArviZ
random variables). Use this when ``value`` is a pandas Series or DataFrame. The
``dims`` will then be the name of the Series / DataFrame's columns. See ArviZ
documentation for more information about dimensions and coordinates:
:ref:`arviz:quickstart`.
export_index_as_coords: bool, optional, default=False
If True, the `Data` container will try to infer what the coordinates should be
if there is an index in `value`.
**kwargs: dict, optional
If this parameter is not specified, the random variables will not have dimension
names.
export_index_as_coords : bool, default=False
If True, the ``Data`` container will try to infer what the coordinates should be
if there is an index in ``value``.
mutable : bool, optional
Switches between creating a :class:`~aesara.compile.sharedvalue.SharedVariable`
(``mutable=True``) vs. creating a :class:`~aesara.tensor.TensorConstant`
(``mutable=False``).
Consider using :class:`pymc.ConstantData` or :class:`pymc.MutableData` as less
verbose alternatives to ``pm.Data(..., mutable=...)``.
If this parameter is not specified, the value it takes will depend on the
version of the package. Since ``v4.1.0`` the default value is
``mutable=False``, with previous versions having ``mutable=True``.
**kwargs : dict, optional
Extra arguments passed to :func:`aesara.shared`.

Examples
--------

>>> import pymc as pm
>>> import numpy as np
>>> # We generate 10 datasets
Expand All @@ -609,12 +622,6 @@ def Data(
... # Switch out the observed dataset
... model.set_data('data', data_vals)
... idatas.append(pm.sample())

To set the value of the data container variable, check out
:func:`pymc.model.set_data()`.

For more information, take a look at this example notebook
https://docs.pymc.io/notebooks/data_container.html
"""
if isinstance(value, list):
value = np.array(value)
Expand Down