def _gen_bus_info(ppc, idx_gen):
    bus_name = int(ppc['gen'][(idx_gen, GEN_BUS)])
    idx_bus = int(where((ppc['bus'][:, BUS_I] == bus_name))[0][0])
    current_bus_type = int(ppc['bus'][(idx_bus, 1)])
    same_bus_gen_idx = where((ppc['gen'][:, GEN_BUS] == ppc['gen'][(idx_gen, GEN_BUS)]))[0].astype(int)
    same_bus_in_service_gen_idx = same_bus_gen_idx[where((ppc['gen'][(same_bus_gen_idx, GEN_STATUS)] > 0))]
    first_same_bus_in_service_gen_idx = (same_bus_in_service_gen_idx[0] if len(same_bus_in_service_gen_idx) else None)
    last_same_bus_in_service_gen_idx = (same_bus_in_service_gen_idx[(- 1)] if len(same_bus_in_service_gen_idx) else None)
    return (current_bus_type, idx_bus, same_bus_gen_idx, first_same_bus_in_service_gen_idx, last_same_bus_in_service_gen_idx)
def _gen_bus_info(ppc, idx_gen):
    bus_name = int(ppc['gen'][(idx_gen, GEN_BUS)])
    idx_bus = int(where((ppc['bus'][:, BUS_I] == bus_name))[0][0])
    current_bus_type = int(ppc['bus'][(idx_bus, 1)])
    same_bus_gen_idx = where((ppc['gen'][:, GEN_BUS] == ppc['gen'][(idx_gen, GEN_BUS)]))[0].astype(int)
    same_bus_in_service_gen_idx = same_bus_gen_idx[where((ppc['gen'][(same_bus_gen_idx, GEN_STATUS)] > 0))]
    first_same_bus_in_service_gen_idx = (same_bus_in_service_gen_idx[0] if len(same_bus_in_service_gen_idx) else None)
    last_same_bus_in_service_gen_idx = (same_bus_in_service_gen_idx[(- 1)] if len(same_bus_in_service_gen_idx) else None)
    return (current_bus_type, idx_bus, same_bus_gen_idx, first_same_bus_in_service_gen_idx, last_same_bus_in_service_gen_idx)