Beispiel #1
0
 def find_3d_class_number(self, index_2d, freq_array):
     assert (len(index_2d) == len(freq_array))
     sub_classes_nrepeat = self.sub_classes_nrepeat
     cumsum_n_subclass = self.cumsum_n_subclass
     ind_3d_array = np.zeros(len(index_2d), dtype=np.int)
     for i in range(len(index_2d)):
         class_2d = index_2d[i]
         freq = freq_array[i]
         sub_class_array = sub_classes_nrepeat[class_2d]
         ind_repeat = np.array(bs.bisect_left(sub_class_array, freq))
         # check out of bounds
         fix_bisect_left_indices(ind_repeat, sub_class_array)
         ind_3d_array[i] = cumsum_n_subclass[class_2d] + ind_repeat
     return ind_3d_array
Beispiel #2
0
 def find_3d_class_number(self, index_2d, freq_array):
     #find the (v, sgn(v)) class number
     #index_2d = class_index_abs_log(v_array, v_log_edges)
     sub_classes_nrepeat = self.sub_classes_nrepeat
     cumsum_n_subclass = self.cumsum_n_subclass
     ind_3d_array = np.zeros(len(index_2d))
     for i in range(len(index_2d)):
         class_2d = index_2d[i]
         freq = freq_array[i]
         sub_class_array = sub_classes_nrepeat[class_2d]
         ind_repeat = np.array(bs.bisect_left(sub_class_array, freq))
         #check out of bounds
         fix_bisect_left_indices(ind_repeat, sub_class_array)
         ind_3d_array[i] = cumsum_n_subclass[class_2d] + ind_repeat
     return ind_3d_array
Beispiel #3
0
def find_extended_class_number(primary_index_array, freq_array,
                               sub_classes_nrepeat, cumsum_n_subclass):
    """
    convert (primary_idx, f) to a single extended index
    :param primary_index_array:
    :param freq_array:
    :param sub_classes_nrepeat:
    :param cumsum_n_subclass:
    :return:
    """
    assert (len(primary_index_array) == len(freq_array))
    sub_classes_nrepeat = sub_classes_nrepeat
    cumsum_n_subclass = cumsum_n_subclass
    extended_index_array = np.zeros(len(primary_index_array), dtype=np.int)
    for i in range(len(primary_index_array)):
        class_2d = primary_index_array[i]
        freq = freq_array[i]
        sub_class_array = sub_classes_nrepeat[class_2d]
        ind_repeat = np.array(bs.bisect_left(sub_class_array, freq))
        # check out of bounds
        fix_bisect_left_indices(ind_repeat, sub_class_array)
        extended_index_array[i] = cumsum_n_subclass[class_2d] + ind_repeat
    return extended_index_array