def idxgen(run, timestamps=None, first=None, last=None):
    if (timestamps is None):
        timestamps = run.times()
    if (first is None):
        first = 0
    if (last is None):
        last = len(timestamps)
    else:
        last = min(last, len(timestamps))
    if (size == 1):
        nom = rank
        denom = size
    else:
        nom = (rank - 1)
        denom = (size - 1)
    times = timestamps[first:last]
    nevents = len(times)
    (mytimes, myevents) = zip(*[(times[i], i) for i in range(nevents) if (((i + nom) % denom) == 0)])
    for j in range(len(mytimes)):
        (yield (myevents[j], run.event(mytimes[j])))
def idxgen(run, timestamps=None, first=None, last=None):
    if (timestamps is None):
        timestamps = run.times()
    if (first is None):
        first = 0
    if (last is None):
        last = len(timestamps)
    else:
        last = min(last, len(timestamps))
    if (size == 1):
        nom = rank
        denom = size
    else:
        nom = (rank - 1)
        denom = (size - 1)
    times = timestamps[first:last]
    nevents = len(times)
    (mytimes, myevents) = zip(*[(times[i], i) for i in range(nevents) if (((i + nom) % denom) == 0)])
    for j in range(len(mytimes)):
        (yield (myevents[j], run.event(mytimes[j])))