def _run_ems(objective_function, data, cond_idx, train, test):
 d = objective_function(*(data[np.intersect1d(c, train)] for c in cond_idx))
 d /= np.sqrt(np.sum((d ** 2), axis=0))[None, :]
 return (np.sum((data[test[0]] * d), axis=0), d)

def _run_ems ( objective_function , data , cond_idx , train , test ) : d = objective_function ( * ( data [ np . intersect1d ( c , train ) ] for c in cond_idx ) ) d /= np . sqrt ( np . sum ( ( d ** 2 ) , axis = 0 ) ) [ None , : ] return ( np . sum ( ( data [ test [ 0 ] ] * d ) , axis = 0 ) , d )
run ems .