@scope.define_info(o_len=2)
def ap_filter_trials(o_idxs, o_vals, l_idxs, l_vals, gamma, gamma_cap=DEFAULT_LF):
 (o_idxs, o_vals, l_idxs, l_vals) = list(map(np.asarray, [o_idxs, o_vals, l_idxs, l_vals]))
 n_below = min(int(np.ceil((gamma * np.sqrt(len(l_vals))))), gamma_cap)
 l_order = np.argsort(l_vals)
 keep_idxs = set(l_idxs[l_order[:n_below]])
 below = [v for (i, v) in zip(o_idxs, o_vals) if (i in keep_idxs)]
 if 0:
  print('DEBUG: thresh', l_vals[l_order[:n_below]])
 keep_idxs = set(l_idxs[l_order[n_below:]])
 above = [v for (i, v) in zip(o_idxs, o_vals) if (i in keep_idxs)]
 return (np.asarray(below), np.asarray(above))

@ scope . define_info ( o_len = 2 ) def ap_filter_trials ( o_idxs , o_vals , l_idxs , l_vals , gamma , gamma_cap = DEFAULT_LF ) : ( o_idxs , o_vals , l_idxs , l_vals ) = list ( map ( np . asarray , [ o_idxs , o_vals , l_idxs , l_vals ] ) ) n_below = min ( int ( np . ceil ( ( gamma * np . sqrt ( len ( l_vals ) ) ) ) ) , gamma_cap ) l_order = np . argsort ( l_vals ) keep_idxs = set ( l_idxs [ l_order [ : n_below ] ] ) below = [ v for ( i , v ) in zip ( o_idxs , o_vals ) if ( i in keep_idxs ) ] if 0 : print ( 'DEBUG: thresh' , l_vals [ l_order [ : n_below ] ] ) keep_idxs = set ( l_idxs [ l_order [ n_below : ] ] ) above = [ v for ( i , v ) in zip ( o_idxs , o_vals ) if ( i in keep_idxs ) ] return ( np . asarray ( below ) , np . asarray ( above ) )
return the elements of o_vals that correspond to trials whose losses were above gamma .