Ignore:
Timestamp:
01/08/13 12:53:51 (16 months ago)
Author:
astaric
Branch:
default
Message:

Python 2.6 compatibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/classification/logreg.py

    r11060 r11063  
    4242    out.append(formatstr % ("Feature", "beta", "st. error", "wald Z", "P", "OR=exp(beta)")) 
    4343    out.append('') 
    44     formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f"     
     44    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f" 
    4545    out.append(formatstr % ("Intercept", classifier.beta[0], classifier.beta_se[0], classifier.wald_Z[0], classifier.P[0])) 
    46     formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %s"     
     46    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %s" 
    4747    for i in range(len(classifier.continuized_domain.features)): 
    48         exp = decimal.Decimal(math.e) ** decimal.Decimal(classifier.beta[i+1]) 
     48        try: 
     49            exp = decimal.Decimal(math.e) ** decimal.Decimal(classifier.beta[i+1]) 
     50        except TypeError: 
     51            # Python 2.6 does not support creating Decimals from float 
     52            exp = decimal.Decimal(str(math.e)) ** decimal.Decimal(str(classifier.beta[i+1])) 
    4953        out.append(formatstr % (classifier.continuized_domain.features[i].name, 
    5054            classifier.beta[i+1], 
     
    5559 
    5660    return '\n'.join(out) 
    57          
     61 
    5862 
    5963def has_discrete_values(domain): 
Note: See TracChangeset for help on using the changeset viewer.