On Wed, Dec 16, 2015 at 3:15 AM, Robert <rxjw...@gmail.com> wrote: > 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 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. > > This is quite different from my any other language experience. > > Could you help me on this?
What this suggests is that the call you're doing returns something (as every function call must, unless it raises an exception or doesn't terminate), but it also has side effects. You're ignoring the return value (which is why "data = " doesn't affect your code), but you need the side effects. Unfortunately this is the case with quite a lot of Python's high end math/stats modules, presumably because their APIs are lifted directly from other languages; have a look at pyplot, for instance, where a more Pythonic API would be to instantiate a plot object every time. (In that particular example, I believe that's an option; but most examples just use the module-level default.) It's my guess (based on skimming the docs) that the objects passed in, including those referenced as function default arguments, are getting mutated. But I'm no expert on pymc. It's equally likely that module-level (global) state is being changed. ChrisA -- https://mail.python.org/mailman/listinfo/python-list