class_docstr: This class implements the core of the basinhopping algorithm.
  
  x0 : ndarray
      The starting coordinates.
  minimizer : callable
      The local minimizer, with signature ``result = minimizer(x)``.
      The return value is an `optimize.OptimizeResult` object.
  step_taking : callable
      This function displaces the coordinates randomly. Signature should
      be ``x_new = step_taking(x)``. Note that `x` may be modified in-place.
  accept_tests : list of callables
      Each test is passed the kwargs `f_new`, `x_new`, `f_old` and
      `x_old`. These tests will be used to judge whether or not to accept
      the step. The acceptable return values are True, False, or ``"force
      accept"``. If any of the tests return False then the step is rejected.
      If ``"force accept"``, then this will override any other tests in
      order to accept the step. This can be used, for example, to forcefully
      escape from a local minimum that ``basinhopping`` is trapped in.
  disp : bool, optional
      Display status messages.
class_docstr_tok: ["This","class","implements","the","core","of","the","basinhopping","algorithm",".","x0",":","ndarray","The","starting","coordinates",".","minimizer",":","callable","The","local","minimizer",",","with","signature","``","result","=","minimizer","(","x",")","``",".","The","return","value","is","an","`","optimize.OptimizeResult","`","object",".","step_taking",":","callable","This","function","displaces","the","coordinates","randomly",".","Signature","should","be","``","x_new","=","step_taking","(","x",")","``",".","Note","that","`","x","`","may","be","modified","in-place",".","accept_tests",":","list","of","callables","Each","test","is","passed","the","kwargs","`","f_new","`",",","`","x_new","`",",","`","f_old","`","and","`","x_old","`",".","These","tests","will","be","used","to","judge","whether","or","not","to","accept","the","step",".","The","acceptable","return","values","are","True",",","False",",","or","``","``","force","accept","''","``",".","If","any","of","the","tests","return","False","then","the","step","is","rejected",".","If","``","``","force","accept","''","``",",","then","this","will","override","any","other","tests","in","order","to","accept","the","step",".","This","can","be","used",",","for","example",",","to","forcefully","escape","from","a","local","minimum","that","``","basinhopping","``","is","trapped","in",".","disp",":","bool",",","optional","Display","status","messages","."]
docstr: Do one Monte Carlo iteration
  
  Randomly displace the coordinates, minimize, and decide whether
  or not to accept the new coordinates.
docstr_tok: ["Do","one","Monte","Carlo","iteration","Randomly","displace","the","coordinates",",","minimize",",","and","decide","whether","or","not","to","accept","the","new","coordinates","."]
code: def _monte_carlo_step(self):
      """Do one Monte Carlo iteration
  
      Randomly displace the coordinates, minimize, and decide whether
      or not to accept the new coordinates.
      """
      # Take a random step.  Make a copy of x because the step_taking
      # algorithm might change x in place
      x_after_step = np.copy(self.x)
      x_after_step = self.step_taking(x_after_step)
  
      # do a local minimization
      minres = self.minimizer(x_after_step)
      x_after_quench = minres.x
      energy_after_quench = minres.fun
      if not minres.success:
          self.res.minimization_failures += 1
          if self.disp:
              print("warning: basinhopping: local minimization failure")
  
      if hasattr(minres, "nfev"):
          self.res.nfev += minres.nfev
      if hasattr(minres, "njev"):
          self.res.njev += minres.njev
      if hasattr(minres, "nhev"):
          self.res.nhev += minres.nhev
  
      # accept the move based on self.accept_tests. If any test is False,
      # then reject the step.  If any test returns the special string
      # 'force accept', then accept the step regardless. This can be used
      # to forcefully escape from a local minimum if normal basin hopping
      # steps are not sufficient.
      accept = True
      for test in self.accept_tests:
          testres = test(
              f_new=energy_after_quench,
              x_new=x_after_quench,
              f_old=self.energy,
              x_old=self.x,
          )
          if testres == "force accept":
              accept = True
              break
          elif testres is None:
              raise ValueError(
                  "accept_tests must return True, False, or "
                  "'force accept'"
              )
          elif not testres:
              accept = False
  
      # Report the result of the acceptance test to the take step class.
      # This is for adaptive step taking
      if hasattr(self.step_taking, "report"):
          self.step_taking.report(
              accept,
              f_new=energy_after_quench,
              x_new=x_after_quench,
              f_old=self.energy,
              x_old=self.x,
          )
  
      return accept, minres
  
imports: import numpy
  import math
  from numpy import cos, sin
  import scipy.optimize
  from scipy._lib._util import check_random_state
label_desc: Use image node_id 2 for calling the BasinHoppingRunner obj's underlying member method code with example usage: obj._monte_carlo_step() and returns: accept,  minres