Help on code comprehension from an example project of pymc
Terry Reedy
tjreedy at udel.edu
Tue Dec 15 17:45:01 EST 2015
On 12/15/2015 11:15 AM, Robert wrote:
> Hi,
>
> I find the useful small code project for me:
> #https://users.obs.carnegiescience.edu/cburns/ipynbs/PyMC.html
>
> It runs as expected.
>
> When I review the code, I find 'data' in the original line:
>
> data = pymc.Normal('data', mu=model, tau=tau, value=z_obs, observed=True)
>
> has not been referenced thereafter.
If the function is called strictly for its side-effect, then it would be
normal to not keep the 'return' value. Code checkers will catch this
and warn. Just because code is make available, does not mean it follows
the best style. Perhaps the programmer though 'data' might be needed
before writing the rest.
> If I comment out the line as:
>
> #data = pymc.Normal('data', mu=model, tau=tau, value=z_obs, observed=True)
>
> the result is ugly different from the original.
>
> If I change it to:
>
> pymc.Normal('data', mu=model, tau=tau, value=z_obs, observed=True)
>
> it still runs as the original.
--
Terry Jan Reedy
More information about the Python-list
mailing list