def next_event_indexer(all_dates, all_sids, event_dates, event_timestamps, event_sids):
 validate_event_metadata(event_dates, event_timestamps, event_sids)
 out = np.full((len(all_dates), len(all_sids)), (-1), dtype=np.int64)
 sid_ixs = all_sids.searchsorted(event_sids)
 dt_ixs = all_dates.searchsorted(event_dates, side='right')
 ts_ixs = all_dates.searchsorted(event_timestamps)
 for i in range((len(event_sids) - 1), (-1), (-1)):
  start_ix = ts_ixs[i]
  end_ix = dt_ixs[i]
  out[start_ix:end_ix, sid_ixs[i]] = i
 return out

def next_event_indexer ( all_dates , all_sids , event_dates , event_timestamps , event_sids ) : validate_event_metadata ( event_dates , event_timestamps , event_sids ) out = np . full ( ( len ( all_dates ) , len ( all_sids ) ) , ( - 1 ) , dtype = np . int64 ) sid_ixs = all_sids . searchsorted ( event_sids ) dt_ixs = all_dates . searchsorted ( event_dates , side = 'right' ) ts_ixs = all_dates . searchsorted ( event_timestamps ) for i in range ( ( len ( event_sids ) - 1 ) , ( - 1 ) , ( - 1 ) ) : start_ix = ts_ixs [ i ] end_ix = dt_ixs [ i ] out [ start_ix : end_ix , sid_ixs [ i ] ] = i return out
construct an index array that .