docstr: Test executing a single step of the RotosolveOptimizer on a QNode.
docstr_tok: ["Test","executing","a","single","step","of","the","RotosolveOptimizer","on","a","QNode","."]
code: def test_single_step(
      self,
      qnode,
      param,
      nums_frequency,
      spectra,
      substep_optimizer,
      substep_kwargs,
  ):
      """Test executing a single step of the RotosolveOptimizer on a QNode."""
      param = tuple(np.array(p, requires_grad=True) for p in param)
      opt = RotosolveOptimizer(substep_optimizer, substep_kwargs)
  
      repack_param = len(param) == 1
      new_param_step = opt.step(
          qnode,
          *param,
          nums_frequency=nums_frequency,
          spectra=spectra,
      )
      if repack_param:
          new_param_step = (new_param_step,)
  
      assert (
          np.isscalar(new_param_step) and np.isscalar(param)
      ) or len(new_param_step) == len(param)
      # pylint:disable=unbalanced-tuple-unpacking
      new_param_step_and_cost, old_cost = opt.step_and_cost(
          qnode,
          *param,
          nums_frequency=nums_frequency,
          spectra=spectra,
      )
      if repack_param:
          new_param_step_and_cost = (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),
      )
      assert np.isclose(qnode(*param), old_cost)
  
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 TestWithQNodes obj's underlying member method code with example usage: obj.test_single_step(qnode, param, nums_frequency, spectra, substep_optimizer, substep_kwargs) without return types