Felix Steffenhagen wrote: [snip] > In:
http://www.informatik.uni-freiburg.de/~steffenh/bayes.py
> [bayes.test gives different results each time it is called]
Without looking in the slightest at what you are implementing or how, this implies that state is maintained between calls to test
The question is where/how is the state maintained?
1) global module variables? - you don't have any 2) attributes of global objects?
I used:
>>> def attrs(obj):
... return dict((name,getattr(obj,name)) for name in dir(obj) if not callable(getattr(obj, name)) and name not in ("__doc__","__module__"))
to verify that the classes are not gaining (non-callable) attributes
3) as mutable default parameters?
See:
line 135: def __init__(self,V,E,p=[]):
line 150: def generate_cpd(self,node, rest, values={}):
line 360: def computeJPD(self, rest, values={}):I guess one (or more) of these is the culprit
Before running:
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> bayesNet.generate_cpd.func_defaults
({},)
>>> bayesNet.__init__.func_defaults
([],)
>>> bayesNet.computeJPD.func_defaults
({},)
>>> test()
V = {'a': [0, 1], 'b': [0, 1]}
[snip results]After test:
>>> bayesNet.generate_cpd.func_defaults
({'a': 1, 'b': 1},)
>>> bayesNet.__init__.func_defaults
([],)
>>> bayesNet.computeJPD.func_defaults
({'a': 1, 'b': 1},)
>>>HTH
Michael
-- http://mail.python.org/mailman/listinfo/python-list
