docstr: Tests convergence for easy classical functions in a single Rotosolve step
  with some arguments deactivated for training.
  Includes testing of the parameter output shape and the old cost when using step_and_cost.
docstr_tok: ["Tests","convergence","for","easy","classical","functions","in","a","single","Rotosolve","step","with","some","arguments","deactivated","for","training",".","Includes","testing","of","the","parameter","output","shape","and","the","old","cost","when","using","step_and_cost","."]
code: def test_single_step(self, fun, x_min, param, num_freq):
      """Tests convergence for easy classical functions in a single Rotosolve step
      with some arguments deactivated for training.
      Includes testing of the parameter output shape and the old cost when using step_and_cost.
      """
      substep_optimizer = "brute"
      substep_kwargs = None
      opt = RotosolveOptimizer(substep_optimizer, substep_kwargs)
  
      new_param_step = opt.step(
          fun,
          *param,
          nums_frequency=num_freq,
      )
      # The following accounts for the unpacking functionality for length-1 param
      if len(param) == 1:
          new_param_step = (new_param_step,)
  
      assert len(x_min) == len(new_param_step)
      assert np.allclose(
          np.fromiter(_flatten(x_min), dtype=float),
          np.fromiter(_flatten(new_param_step), dtype=float),
          atol=1e-5,
      )
  
      # pylint:disable=unbalanced-tuple-unpacking
      new_param_step_and_cost, old_cost = opt.step_and_cost(
          fun,
          *param,
          nums_frequency=num_freq,
      )
      # The following accounts for the unpacking functionality for length-1 param
      if len(param) == 1:
          new_param_step_and_cost = (new_param_step_and_cost,)
  
      assert len(x_min) == len(new_param_step_and_cost)
      assert np.allclose(
          np.fromiter(_flatten(new_param_step_and_cost), dtype=float),
          np.fromiter(_flatten(new_param_step), dtype=float),
          atol=1e-5,
      )
      assert np.isclose(old_cost, fun(*param))
  
imports: import functools
  import pytest
  from scipy.optimize import shgo
  import pennylane
  from pennylane import numpy
  from pennylane.utils import _flatten, unflatten
  from pennylane.optimize import RotosolveOptimizer
label_desc: Use image node_id 1 for calling the TestDeactivatedTrainingWithClassicalFunctions obj's underlying member method code with example usage: obj.test_single_step(fun, x_min, param, num_freq) without return types