Coverage for /home/kale/.local/lib/python3.4/site-packages/nonstdlib/misc : 30%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# encoding: utf-8
# I really think that an 'infinity' constant should be built into the language, # just like '0' or 'None'. But it isn't, so I have to define it here instead.
from numpy import linspace return list(linspace(start, stop, num=count))
if lowest > highest: lowest, highest = highest, lowest return min(max(value, lowest), highest)
return list(yield_partitioned(iterable, chunks))
return list(yield_binned(iterable, count))
return list(yield_flattened(iterable))
start, end = 0, 0 list_size = len(iterable) chunk_size = int(list_size / chunks + 0.5)
for index in range(chunks - 1): start = index * chunk_size end = start + chunk_size yield iterable[start:end]
yield iterable[end:]
views = itertools.tee(iterable, count)
for index, view in enumerate(views): for x in range(index): next(view, None)
return itertools.izip(*views)
for item in iterable: if not is_iterable(item): yield item
else: for subitem in flatten(iterable): yield subitem
try: iter(obj) except: return False return isinstance(obj, basestring)
total = sum(w for w in weights) threshold = random.uniform(0, total) weight_sum = 0
for choice, weight in zip(choices, weights): weight_sum += weight if weight_sum > threshold: return choice
# Barring some sort of floating point error, we should never get this far. # But if we do, returning the last choice is clearly the right action.
return choices[-1]
|