@@ -39,6 +39,22 @@ def get_context(cls):
3939 raise TypeError ("No context on context stack" )
4040
4141def withcontext (contexttype , argname ):
42+ """
43+ Returns a decorator for wrapping functions so they look for an argument in a specific argument slot.
44+ If not found, the decorated function searches the for a context and inserts it in that slot.
45+
46+ Parameters
47+ ----------
48+ contexttype : type
49+ The type of context to search for
50+ argname : string
51+ The name of the argument slot where the context should go
52+
53+ Returns
54+ -------
55+ decorator function
56+
57+ """
4258 def decorator (fn ):
4359 n = list (fn .func_code .co_varnames ).index (argname )
4460
@@ -83,20 +99,25 @@ def logp(model):
8399
84100 @property
85101 def logpc (model ):
102+ """Compiled log probability density function"""
86103 return compilef (model .logp )
87104
88105 def dlogpc (model , vars = None ):
106+ """Compiled log probability density gradient function"""
89107 return compilef (gradient (model .logp , vars ))
90108
91109 def d2logpc (model , vars = None ):
110+ """Compiled log probability density hessian function"""
92111 return compilef (hessian (model .logp , vars ))
93112
94113 @property
95114 def test_point (self ):
115+ """Test point used to check that the model doesn't generate errors"""
96116 return Point (self , ((var , var .tag .test_value ) for var in self .vars ))
97117
98118 @property
99119 def cont_vars (model ):
120+ """All the continuous variables in the model"""
100121 return typefilter (model .vars , continuous_types )
101122
102123 """
@@ -144,6 +165,18 @@ def Point(model, *args,**kwargs):
144165
145166
146167def compilef (outs , mode = None ):
168+ """
169+ Compiles a Theano function which returns `outs` and takes the variable ancestors of `outs` as inputs.
170+
171+ Parameters
172+ ----------
173+ outs : Theano variable or iterable of Theano variables
174+ mode : Theano compilation mode
175+
176+ Returns
177+ -------
178+ Compiled Theano function
179+ """
147180 return PointFunc (
148181 function (inputvars (outs ), outs ,
149182 allow_input_downcast = True ,
0 commit comments