MCPcopy Create free account
hub / github.com/ActiveState/code / changes

Function changes

recipes/Python/577515_interval_mapping/recipe-577515.py:272–287  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

270 values = [m.leftmost() for m in mappings]
271
272 def changes():
273
274 def start_i_value(i_m):
275 i, m = i_m
276 res = ((k.start, i, v) for k, v in m.iteritems(True))
277 next(res)
278 return res
279 change_points = merge(*map(start_i_value, enumerate(mappings)))
280
281 lastbound = None
282 for bound, i, v in change_points:
283 values[i] = v
284 if bound != lastbound:
285 yield bound, func(*values)
286 lastbound = bound
287 yield bound, func(*values)
288
289 return IntervalMapping.from_changes(func(*values), changes())
290

Callers 1

applyFunction · 0.85

Calls 4

mapFunction · 0.85
mergeFunction · 0.50
enumerateFunction · 0.50
funcFunction · 0.50

Tested by

no test coverage detected