def step(sampler, x, delta, fraction=None, tries=<NUM_LIT:0>):
prob = sampler.problem<EOL>valid = ((np.abs(delta) > sampler.feasibility_tol) &<EOL>np.logical_not(prob.variable_fixed))<EOL>valphas = ((<NUM_LIT:1.0> - sampler.bounds_tol) * prob.variable_bounds -<EOL>x)[:, valid]<EOL>valphas = (valphas / delta[valid]).flatten()<EOL>if prob.bounds.shape[<NUM_LIT:0>] > <NUM_LIT:0>:<EOL><INDENT>ineqs = prob.inequalities.dot(delta)<EOL>valid = np.abs(ineqs) > sampler.feasibility_tol<EOL>balphas = ((<NUM_LIT:1.0> - sampler.bounds_tol) * prob.bounds -<EOL>prob.inequalities.dot(x))[:, valid]<EOL>balphas = (balphas / ineqs[valid]).flatten()<EOL>alphas = np.hstack([valphas, balphas])<EOL><DEDENT>else:<EOL><INDENT>alphas = valphas<EOL><DEDENT>pos_alphas = alphas[alphas > <NUM_LIT:0.0>]<EOL>neg_alphas = alphas[alphas <= <NUM_LIT:0.0>]<EOL>alpha_range = np.array([neg_alphas.max() if len(neg_alphas) > <NUM_LIT:0> else <NUM_LIT:0>,<EOL>pos_alphas.min() if len(pos_alphas) > <NUM_LIT:0> else <NUM_LIT:0>])<EOL>if fraction:<EOL><INDENT>alpha = alpha_range[<NUM_LIT:0>] + fraction * (alpha_range[<NUM_LIT:1>] - alpha_range[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>alpha = np.random.uniform(alpha_range[<NUM_LIT:0>], alpha_range[<NUM_LIT:1>])<EOL><DEDENT>p = x + alpha * delta<EOL>if (np.any(sampler._bounds_dist(p) < -sampler.bounds_tol) or<EOL>np.abs(np.abs(alpha_range).max() * delta).max() <<EOL>sampler.bounds_tol):<EOL><INDENT>if tries > MAX_TRIES:<EOL><INDENT>raise RuntimeError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>LOGGER.info("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>newdir = sampler.warmup[np.random.randint(sampler.n_warmup)]<EOL>sampler.retries += <NUM_LIT:1><EOL>return step(sampler, sampler.center, newdir - sampler.center, None,<EOL>tries + <NUM_LIT:1>)<EOL><DEDENT>return p<EOL>
Sample a new feasible point from the point `x` in direction `delta`.