annotate pylearn/datasets/embeddings/percent.py @ 538:798607a058bd

added missing files
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 12 Nov 2008 22:00:20 -0500
parents
children
rev   line source
538
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
1 def percent(a, b):
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
2 """
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
3 Return percentage string of a and b, e.g.:
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
4 "1 of 10 (10%)"
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
5 """
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
6 assert a <= b
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
7 assert a >= 0
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
8 assert b > 0
798607a058bd added missing files
James Bergstra <bergstrj@iro.umontreal.ca>
parents:
diff changeset
9 return "%s of %s (%.2f%%)" % (a, b, 100.*a/b)