Commits

astaric committed 68bc42e

Python 2.6 compatibility.

Comments (0)

Files changed (1)

Orange/classification/logreg.py

     formatstr = "%"+str(longest)+"s %10s %10s %10s %10s %10s"
     out.append(formatstr % ("Feature", "beta", "st. error", "wald Z", "P", "OR=exp(beta)"))
     out.append('')
-    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f"    
+    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f"
     out.append(formatstr % ("Intercept", classifier.beta[0], classifier.beta_se[0], classifier.wald_Z[0], classifier.P[0]))
-    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %s"    
+    formatstr = "%"+str(longest)+"s %10.2f %10.2f %10.2f %10.2f %s"
     for i in range(len(classifier.continuized_domain.features)):
-        exp = decimal.Decimal(math.e) ** decimal.Decimal(classifier.beta[i+1])
+        try:
+            exp = decimal.Decimal(math.e) ** decimal.Decimal(classifier.beta[i+1])
+        except TypeError:
+            # Python 2.6 does not support creating Decimals from float
+            exp = decimal.Decimal(str(math.e)) ** decimal.Decimal(str(classifier.beta[i+1]))
         out.append(formatstr % (classifier.continuized_domain.features[i].name,
             classifier.beta[i+1],
             classifier.beta_se[i+1],
             format_decimal(exp)))
 
     return '\n'.join(out)
-        
+
 
 def has_discrete_values(domain):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.