Skip to content
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

Get the transform docs into the API pages. #3690

Merged
merged 12 commits into from
Nov 26, 2019
1 change: 1 addition & 0 deletions docs/source/api/distributions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Distributions
distributions/multivariate
distributions/mixture
distributions/timeseries
distributions/transforms
distributions/utilities
93 changes: 93 additions & 0 deletions docs/source/api/distributions/transforms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
*******************************************
Transformations of a random variable from one space to another.
*******************************************

.. currentmodule:: pymc3.distributions.transforms
.. autosummary::

transform
stick_breaking
logodds
interval
log_exp_m1
lowerbound
upperbound
ordered
log
sum_to_1
t_stick_breaking
circular
CholeskyCovPacked
Chain

Transform Instances
~~~~~~~~~~~~~~~~~~~

Transform instances are the entities that should be used in the
`transform` parameter to a random variable constructor. These are
initialized instances of the Transform Classes, which are described
below.

.. autodata:: stick_breaking
.. autodata:: logodds
.. autodata:: interval
.. autodata:: log_exp_m1
.. autodata:: lowerbound
.. autodata:: upperbound
.. autodata:: ordered
.. autodata:: log
.. autodata:: sum_to_1
.. autodata:: t_stick_breaking
.. autodata:: circular

Transform Base Classes
~~~~~~~~~~~~~~~~~~~~~~

Typically the programmer will not use these directly.

.. autoclass:: Transform
:members:
.. autoclass:: transform
:members:
.. autoclass:: TransformedDistribution
:members:


Transform Composition Classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: Chain
:members:
.. autoclass:: CholeskyCovPacked


Specific Transform Classes
~~~~~~~~~~~~~~~~~

.. autoclass:: Log
:members:
.. autoclass:: LogExpM1
:members:
.. autoclass:: LogOdds
:members:
.. autoclass:: Interval
:members:
.. autoclass:: LowerBound
:members:
.. autoclass:: UpperBound
:members:
.. autoclass:: Ordered
:members:
.. autoclass:: SumTo1
:members:
.. autoclass:: StickBreaking
:members:
.. autoclass:: Circular
:members:







6 changes: 1 addition & 5 deletions pymc3/distributions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@
from .timeseries import MvGaussianRandomWalk
from .timeseries import MvStudentTRandomWalk

from .transforms import transform
from .transforms import stick_breaking
from .transforms import logodds
from .transforms import log
from .transforms import sum_to_1
from .transforms import *
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this better than the current method. Two things:

  1. This is technically a breaking change, since pm.distributions.transform will no longer work. I bet this messes up 0 people, but we should add a deprecation warning before removing.
  2. As a suggestion, I think we should surface transforms as pm.transforms, so that you could use pm.transforms.ordered() instead of pm.distributions.ordered() (In fact, I think right now pm.log might be a transform, and not a logarithm?). I think we would do this by not importing anything from .transforms here, but in the top level init, import .distributions.transforms as transforms. How does that sound?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WRT your (1), I think we could just not export transform, since it's just an alias for Transform. That's also theoretically a breaking change, but seems even less likely to cause troubles. Especially since one should not use transform as the name of a class in python.

(2) Sounds good to me.

LMK what you think about my responses and I will make the changes in the PR, or I believe you could do them yourself, if that's what you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of those sound good to me. Feel free to ping after you mess with those imports I'll kick the tires locally (and add tests if I find anything :) ) and then merge. Ooh, I'll check the doc thing you just mentioned, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait -- why is pm.distributions.transform no longer going to work? It's in the __all__ list in transforms.py, so I think it's still ok, isn't it?
But I like the idea of deprecating it, since for a class Transform is preferable. Also transform, not being an initialized entity, doesn't serve the same purpose as the other lower-case names.


from .bound import Bound

Expand Down
4 changes: 3 additions & 1 deletion pymc3/distributions/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"log",
"sum_to_1",
"t_stick_breaking",
"circular",
"CholeskyCovPacked",
"Chain",
]


Expand Down Expand Up @@ -558,7 +561,6 @@ def forward_val(self, y, point=None):
def jacobian_det(self, y):
return tt.sum(y[self.diag_idxs])


class Chain(Transform):
def __init__(self, transform_list):
self.transform_list = transform_list
Expand Down