instantiate new objects

Felix Steffenhagen felix.steffenhagen at gmx.de
Thu Mar 10 18:54:11 EST 2005


The default mutual parameters in the method bayes.generate_cpd(...)
was the problem, thanks alot for the hint and for this code snippet
to find such problems :-).

Greetings,
Felix

Michael Spencer wrote:

> 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?
>.
 >.
 >.
> 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
> 
> 



More information about the Python-list mailing list