[Biopython-dev] [Bug 2697] MaxEntropy calculate function assumes integer values for class and convergence criteria is hard coded

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Jan 30 14:30:40 UTC 2009


------- Comment #9 from biopython-bugzilla at maubp.freeserve.co.uk  2009-01-30 09:30 EST -------
Created an attachment (id=1212)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=1212&action=view)
Patch to Bio/MaxEntropy.py to make the convergence parameters optional

This time its the whole patch - sorry for the extra emails this has triggered. 
I had stopped to check in a couple of docstring changes and fixed a few tabs in
MaxEntropy.py first, which confused things.

Note this is a bit different to what I was thinking in comment #5,
> ... something like this:
> def train(training_set, results, feature_fns, update_fn=None,
>           max_iis_iterations = MAX_IIS_ITERATIONS,
>           iis_convere = IIS_CONVERGE,
>           max_newton_iterations = MAX_NEWTON_ITERATIONS
>           newton_coverage = NEWTON_CONVERGE):

The above code won't pick up changes to the module level variables like
MAX_IIS_ITERATIONS because the defaults are only evaluated once when the
function is created.  The patch deals with this as follows:

def train(training_set, results, feature_fns, update_fn=None,
          max_iis_iterations=None, iis_converge=None,
          max_newton_iterations=None, newton_converge=None):
    if max_iis_iterations is None :
        max_iis_iterations = MAX_IIS_ITERATIONS
    if iis_converge is None :
        iis_converge = IIS_CONVERGE
    if max_newton_iterations is None :
        max_newton_iterations = MAX_NEWTON_ITERATIONS
    if newton_converge is None :
        newton_converge = NEWTON_CONVERGE

This works :)

Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the Biopython-dev mailing list