Skip to content

Instantly share code, notes, and snippets.

@IanHopkinson

IanHopkinson/doctests.py

Last active Dec 18, 2015
Embed
What would you like to do?
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