Skip to content

Commit

Permalink
Fix docstrings of transform.Interval to provide example of how to ins…
Browse files Browse the repository at this point in the history
…tantiate it
  • Loading branch information
ricardoV94 committed Jan 13, 2022
1 parent 6739b11 commit 15b7355
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions pymc/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"RVTransform",
"simplex",
"logodds",
"interval",
"Interval",
"log_exp_m1",
"ordered",
"log",
Expand Down Expand Up @@ -166,10 +166,47 @@ def log_jac_det(self, value, *inputs):
Instantiation of :class:`aeppl.transforms.LogOddsTransform`
for use in the ``transform`` argument of a random variable."""

interval = IntervalTransform
interval.__doc__ = """
Instantiation of :class:`aeppl.transforms.IntervalTransform`
for use in the ``transform`` argument of a random variable."""
Interval = IntervalTransform
Interval.__doc__ = """
Uninstantiated :class:`aeppl.transforms.IntervalTransform`
for use in the ``transform`` argument of a random variable.
Interval transform requires a callable during initialization
which takes takes the underlying random variable inputs and
returns the lower and upper bounds. If lower or upper is `None`,
the interval is unbounded on that side.
.. attention::
The returned bounds cannot depend on other model variables that
are not part of the random variable inputs.
Examples
--------
.. code-block:: python
import pymc as pm
# Create an interval transform between -1 and +1
def get_bounds(rng, size, dtype, loc, scale):
return -1, 1
interval = pm.transforms.Interval(get_bounds)
with pm.Model():
x = pm.Normal("x", transform=interval)
.. code-block:: python
import pymc as pm
# Create an upper bound interval transform based on a distribution parameter
def get_bounds(rng, size, dtype, loc, scale):
return None, loc
interval = pm.transforms.Interval(get_bounds)
with pm.Model():
x = pm.Normal("x", transform=interval)
"""

log_exp_m1 = LogExpM1()
log_exp_m1.__doc__ = """
Expand Down

0 comments on commit 15b7355

Please sign in to comment.