Personal tools
You are here: Home Discussion

Discussion

Up to the Feature Requests Forum
Please feel free to communicate anything you feel could help this project move on. You can receive an email each time a new message is posted by setting up your personal preferences.

Delegate?

Posted by cerin at October 31. 2006
What is the purpose of delegate.py?

The help docs say "Whenever you need to delegate to something, inherit from delegate and use self.__. to access the base."

However, you can do this without the hastle of inheriting by simply doing base.method(self).

If you're just using this code because OpenBayes is based on Robert Dick's Bayesnet (http://ziyang.ece.northwestern.edu/~dickrp/python/mods.html), I highly recommend getting ride of this obfuscated and unnecessary code.

I don't mean to demean anyone's design choices, but I imagine implementing a bayesian network toolkit is difficult enough without reinventing basic language features.

Regards,
Chris
Posted by elliot at November 01. 2006
hmmmmmm.... well we had a reason for this, but now i can't remember it (and it is 8:30am and that just isn't positive for the brain). This basic design decision started in Kosta's (one of the main contributors) original package, which melded with something I had been working on to get us to where we are today. When initially reviewing his code i had the same question. I remember thinking i had an answer to the question that i liked, but now i can't remember what it is. Unfortuneately my computer died on me last night and I can't open the code to remind myself.

Kosta any thoughts...

If he or someone else doesn't get back to you Chris, I should be back in business in a couple of days with an answer.

Elliot
Posted by obadmin at November 04. 2006
Hi cerin,

You're right, the nitial contribution of this piece of code was robert dick's graph module. Actually BayesNet (since you mentionned it) was the name of OpenBayes when it was still young. Later on we switched to OpenBayes.

The delegation class allows for more complex delegation schemes than those defined with python out of the box. It works better in delegations like the following :
a
/ \
b c
\ /
d

where abcd are classes that inherit from the classes above them.
However I do agree that this kind of inheritance schemes are rather rare and do not think we have any of those inside OpenBayes. If we wanted to remove it though, this would imply some slight modifications inside the code.

Thank you for noting this. I had this in my mind for a while and did not take the time to think about it thoroughly. Elliot what do you think, should we remove this?

Kosta
Posted by cerin at November 20. 2006
Hi Kosta,

I still don't quite understand how delegate.py helps. By default, Python allows you to inherit multiple classes by saying:
class A:

def foo(self):
print 'A'

class B(A):
def foo(self):
print 'B'

class C(A):
def foo(self):
print 'C'

class D(B,C):
def foo(self):
B.foo(self)
C.foo(self)

Maybe I'm misunderstanding the use of delegate.py, but what else does it allow you to do? Like you said, if the general use-case is rare, and few people even know why it's being used, then it's probably a good idea to slim down the code.

Regards,
Chris
Posted by cerin at November 20. 2006
Yes you're right.

In the next version delegate.py will not be part of OpenBayes anymore.

This is part of the cleaning up of the code that we are doing for the moment. We will also switch to numpy (instead of numarray).

Thank you for sharing your opinion on the usefulness of this module!

Kosta
Powered by Ploneboard

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: