pymc-devs / pymc2

THIS IS THE **OLD** PYMC PROJECT (VERSION 2). PLEASE USE PYMC INSTEAD:
http://pymc-devs.github.com/pymc/
Other
879 stars 229 forks source link

Access function associated with deterministic #126

Closed ChriZiegler closed 6 years ago

ChriZiegler commented 8 years ago

I want to access the function used to create a deterministic object using the deterministic decorator.

For example, if I have a stochastic:

my_stochastic = pymc.Uniform(name="my_stochastic",lower=0,upper=1)

And a deterministic

@pymc.deterministic
def my_deterministic(name="my_deterministic", x = my_stochastic):
    return(x**2 - x)

Is there a way to access the original my_deterministic function object given the pymc Deterministic object? I want to use line_profiler on the function.

fonnesbeck commented 8 years ago

It will be the _eval_fun attribute:

In [6]: my_deterministic._eval_fun()
Out[6]: <pymc.PyMCObjects.Deterministic '((my_stochastic_pow_2)_sub_my_stochastic)' at 0x118675208>