Skip to content

Instantly share code, notes, and snippets.

@IanHopkinson
Last active December 18, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanHopkinson/5849344 to your computer and use it in GitHub Desktop.
Save IanHopkinson/5849344 to your computer and use it in GitHub Desktop.
A demonstration of doctests
def threshold_above(hist, threshold_value):
"""
>>> threshold_above(collections.Counter({518: 10, 520: 20, 530: 20, 525: 17}), 15)
[520, 530, 525]
"""
if not isinstance(hist,collections.Counter):
raise ValueError("requires collections.Counter")
above = [k for k, v in hist.items() if v > threshold_value]
return above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment