Skip to content

Commit d44de24

Browse files
rloufbrandonwillard
authored andcommitted
Dynamically generate RVTransform list in docs
1 parent 656e5b6 commit d44de24

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

docs/source/api/transforms.rst

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,37 +56,14 @@ associated variables and their values:
5656

5757
.. autoclass:: aeppl.transforms.TransformValuesRewrite
5858

59+
5960
---------------------
6061
Invertible transforms
6162
---------------------
6263

6364
AePPL currently supports transforms using the following (invertible) Aesara operators. This means that AePPL can compute the log-probability of a random variable that is the result of one of the following transformations applied to another random variable:
6465

65-
- `aesara.tensor.add`
66-
- `aesara.tensor.sub`
67-
- `aesara.tensor.mul`
68-
- `aesara.tensor.true_div`
69-
- `aesara.tensor.exponential`
70-
- `aesara.tensor.exp`
71-
- `aesara.tensor.log`
72-
73-
One can also apply the following transforms directly:
74-
75-
.. autoclass:: aeppl.transforms.LocTransform
76-
.. autoclass:: aeppl.transforms.ScaleTransform
77-
.. autoclass:: aeppl.transforms.LogTransform
78-
.. autoclass:: aeppl.transforms.ExpTransform
79-
.. autoclass:: aeppl.transforms.ReciprocalTransform
80-
.. autoclass:: aeppl.transforms.IntervalTransform
81-
.. autoclass:: aeppl.transforms.LogOddsTransform
82-
.. autoclass:: aeppl.transforms.SimplexTransform
83-
.. autoclass:: aeppl.transforms.CircularTransform
84-
85-
These transformations can be chained using:
86-
87-
88-
.. autoclass:: aeppl.transforms.ChainedTransform
89-
66+
.. print-invertible-transforms::
9067

9168
---------
9269
Censoring

docs/source/conf.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,42 @@ def run(self):
112112
return [res]
113113

114114

115+
class InvertibleTransformationsDirective(SphinxDirective):
116+
def run(self):
117+
import inspect
118+
import sys
119+
120+
import aeppl.transforms as transforms
121+
122+
invertible_transforms = (
123+
mname
124+
for mname, mtype in inspect.getmembers(sys.modules["aeppl.transforms"])
125+
if inspect.isclass(mtype)
126+
and issubclass(mtype, transforms.RVTransform)
127+
and not mtype == transforms.RVTransform
128+
)
129+
130+
res = nodes.bullet_list()
131+
for transform_name in invertible_transforms:
132+
attributes = {}
133+
reftarget = f"aeppl.transforms.{transform_name}"
134+
attributes["reftarget"] = reftarget
135+
attributes["reftype"] = "class"
136+
attributes["refdomain"] = "py"
137+
138+
ref = nodes.paragraph()
139+
140+
rawsource = rf":py:class:`{reftarget}`"
141+
xref = sphinx.addnodes.pending_xref(rawsource, **attributes)
142+
xref += nodes.literal(reftarget, reftarget, classes=["xref"])
143+
144+
ref += xref
145+
item = nodes.list_item("", ref)
146+
res += item
147+
148+
return [res]
149+
150+
115151
def setup(app):
116152
app.add_directive("print-supported-dists", SupportedDistributionsDirective)
153+
app.add_directive("print-invertible-transforms", InvertibleTransformationsDirective)

0 commit comments

Comments
 (0)