code: def test_setup_bounds_and_scale_gradient_methods():
      """Tests for the setup_bounds and scale_gradient methods.
  
      Make use of the MINUIT-style transformation to obtain the the Parameter
      values and scaling factor for the gradient.
      See: https://lmfit.github.io/lmfit-py/bounds.html
  
      """
      # situation 1: no bounds
      par_no_bounds = lmfit.Parameter("no_bounds", value=10.0)
      assert_allclose(par_no_bounds.setup_bounds(), 10.0)
      assert_allclose(
          par_no_bounds.scale_gradient(par_no_bounds.value), 1.0
      )
  
      # situation 2: no bounds, min/max set to None after creating the parameter
      # TODO: ideally this should never happen; perhaps use a setter here
      par_no_bounds = lmfit.Parameter("no_bounds", value=10.0)
      par_no_bounds.min = None
      par_no_bounds.max = None
      assert_allclose(par_no_bounds.setup_bounds(), 10.0)
      assert_allclose(
          par_no_bounds.scale_gradient(par_no_bounds.value), 1.0
      )
  
      # situation 3: upper bound
      par_upper_bound = lmfit.Parameter(
          "upper_bound", value=10.0, max=25.0
      )
      assert_allclose(
          par_upper_bound.setup_bounds(), 15.968719422671311
      )
      assert_allclose(
          par_upper_bound.scale_gradient(par_upper_bound.value),
          -0.99503719,
          rtol=1.0e-6,
      )
  
      # situation 4: lower bound
      par_lower_bound = lmfit.Parameter(
          "upper_bound", value=10.0, min=-25.0
      )
      assert_allclose(par_lower_bound.setup_bounds(), 35.98610843)
      assert_allclose(
          par_lower_bound.scale_gradient(par_lower_bound.value),
          0.995037,
          rtol=1.0e-6,
      )
  
      # situation 5: both lower and upper bounds
      par_both_bounds = lmfit.Parameter(
          "both_bounds", value=10.0, min=-25.0, max=25.0
      )
      assert_allclose(
          par_both_bounds.setup_bounds(), 0.4115168460674879
      )
      assert_allclose(
          par_both_bounds.scale_gradient(par_both_bounds.value),
          -20.976788,
          rtol=1.0e-6,
      )
  
imports: from math import trunc
  import pickle
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  import lmfit
label_desc: Use image node_id 20 for calling a global function with example usage: test_setup_bounds_and_scale_gradient_methods() without return types