code: def test_numdifftools_with_bounds(fit_method):
      pytest.importorskip("numdifftools")
  
      # load data to be fitted
      data = np.loadtxt(
          os.path.join(
              os.path.dirname(__file__),
              "..",
              "examples",
              "test_peak.dat",
          )
      )
      x = data[:, 0]
      y = data[:, 1]
  
      # define the model and initialize parameters
      mod = VoigtModel()
      params = mod.guess(y, x=x)
      params["amplitude"].set(min=25, max=70)
      params["sigma"].set(max=1)
      params["center"].set(min=5, max=15)
  
      # do fit, here with leastsq model
      result = mod.fit(y, params, x=x, method="leastsq")
  
      result_ndt = mod.fit(y, params, x=x, method=fit_method)
  
      # assert that fit converged to the same result
      vals = [
          result.params[p].value for p in result.params.valuesdict()
      ]
      vals_ndt = [
          result_ndt.params[p].value
          for p in result_ndt.params.valuesdict()
      ]
      assert_allclose(vals_ndt, vals, rtol=0.1)
      assert_allclose(result_ndt.chisqr, result.chisqr, rtol=1e-5)
  
      # assert that parameter uncertainties from leastsq and calculated from
      # the covariance matrix using numdifftools are very similar
      stderr = [
          result.params[p].stderr for p in result.params.valuesdict()
      ]
      stderr_ndt = [
          result_ndt.params[p].stderr
          for p in result_ndt.params.valuesdict()
      ]
  
      perr = np.array(stderr) / np.array(vals)
      perr_ndt = np.array(stderr_ndt) / np.array(vals_ndt)
      assert_almost_equal(perr_ndt, perr, decimal=3)
  
      # assert that parameter correlatations from leastsq and calculated from
      # the covariance matrix using numdifftools are very similar
      for par1 in result.var_names:
          cor = [
              result.params[par1].correl[par2]
              for par2 in result.params[par1].correl.keys()
          ]
          cor_ndt = [
              result_ndt.params[par1].correl[par2]
              for par2 in result_ndt.params[par1].correl.keys()
          ]
          assert_almost_equal(cor_ndt, cor, decimal=2)
  
file_path: lmfit-py/tests/test_covariance_matrix.py
imports: import os
  import numpy
  from numpy import pi
  from numpy.testing import assert_allclose, assert_almost_equal
  import pytest
  from lmfit import Parameters, minimize
  from lmfit.lineshapes import exponential
  from lmfit.models import ExponentialModel, LinearModel, VoigtModel
label_desc: Use image node_id 5 for calling a global function with example usage: test_numdifftools_with_bounds(fit_method) without return types