def __call__(self, grad, step, f):
stop = True<EOL>status = "<STR_LIT>"<EOL>red = "<STR_LIT>"<EOL>green = "<STR_LIT>"<EOL>reset = "<STR_LIT>"<EOL>def check_threshold(measure, threshold, stop, status):<EOL><INDENT>if threshold is not None:<EOL><INDENT>if measure > threshold:<EOL><INDENT>color = red<EOL>stop = False<EOL><DEDENT>else:<EOL><INDENT>color = green<EOL><DEDENT>status += "<STR_LIT>" % (color, measure, reset)<EOL><DEDENT>return stop, status<EOL><DEDENT>def safe_divide(a, b):<EOL><INDENT>if b == <NUM_LIT:0.0>:<EOL><INDENT>return <NUM_LIT:0.0><EOL><DEDENT>else:<EOL><INDENT>return a/b<EOL><DEDENT><DEDENT>stop, status = check_threshold(np.sqrt((step**<NUM_LIT:2>).mean()), self.step_rms, stop, status)<EOL>stop, status = check_threshold(abs(step).max(), self.step_max, stop, status)<EOL>stop, status = check_threshold(np.sqrt((grad**<NUM_LIT:2>).mean()), self.grad_rms, stop, status)<EOL>stop, status = check_threshold(abs(grad).max(), self.grad_max, stop, status)<EOL>stop, status = check_threshold(safe_divide(np.sqrt((grad**<NUM_LIT:2>).mean()), f), self.rel_grad_rms, stop, status)<EOL>stop, status = check_threshold(safe_divide(abs(grad).max(), f), self.rel_grad_max, stop, status)<EOL>return stop, status<EOL>
Return True when the minimizer has converged

              Arguments:
                | ``grad``  --  The gradient at the current point.
                | ``step``  --  The last step vector.
                | ``f`` -- The last function value.