def _most_frequent(array, extra_value, n_repeat):
 if (array.size > 0):
  mode = stats.mode(array)
  most_frequent_value = mode[0][0]
  most_frequent_count = mode[1][0]
 else:
  most_frequent_value = 0
  most_frequent_count = 0
 if ((most_frequent_count == 0) and (n_repeat == 0)):
  return np.nan
 elif (most_frequent_count < n_repeat):
  return extra_value
 elif (most_frequent_count > n_repeat):
  return most_frequent_value
 elif (most_frequent_count == n_repeat):
  if (most_frequent_value < extra_value):
   return most_frequent_value
  else:
   return extra_value

def _most_frequent ( array , extra_value , n_repeat ) : if ( array . size > 0 ) : mode = stats . mode ( array ) most_frequent_value = mode [ 0 ] [ 0 ] most_frequent_count = mode [ 1 ] [ 0 ] else : most_frequent_value = 0 most_frequent_count = 0 if ( ( most_frequent_count == 0 ) and ( n_repeat == 0 ) ) : return np . nan elif ( most_frequent_count < n_repeat ) : return extra_value elif ( most_frequent_count > n_repeat ) : return most_frequent_value elif ( most_frequent_count == n_repeat ) : if ( most_frequent_value < extra_value ) : return most_frequent_value else : return extra_value
compute the most frequent value in a 1d array extended with [extra_value] * n_repeat .