Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 15d2bfc

Browse files
committed
Changed ndigits to numfmt -- more like other code.
1 parent b3ecb33 commit 15d2bfc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

probability.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def normalize(self):
7171
self.prob[val] /= total
7272
return self
7373

74-
def show_approx(self, ndigits=3):
74+
def show_approx(self, numfmt='%.3g'):
7575
"""Show the probabilities rounded and sorted by key, for the
7676
sake of portable doctests."""
77-
return ', '.join(['%s: %.*g' % (v, ndigits, p)
77+
return ', '.join([('%s: ' + numfmt) % (v, p)
7878
for (v, p) in sorted(self.prob.items())])
7979

8080
epsilon = 0.001

0 commit comments

Comments
 (0)