code: def test_bounded_parameters():
      # create data to be fitted
      np.random.seed(1)
      x = np.linspace(0, 15, 301)
      data = 5.0 * np.sin(2 * x - 0.1) * np.exp(
          -x * x * 0.025
      ) + np.random.normal(size=len(x), scale=0.2)
  
      # define objective function: returns the array to be minimized
      def fcn2min(params, x, data):
          """model decaying sine wave, subtract data"""
          amp = params["amp"]
          shift = params["shift"]
          omega = params["omega"]
          decay = params["decay"]
  
          model = (
              amp * np.sin(x * omega + shift) * np.exp(-x * x * decay)
          )
          return model - data
  
      # create a set of Parameters
      params = Parameters()
      params.add("amp", value=10, min=0, max=50)
      params.add("decay", value=0.1, min=0, max=10)
      params.add("shift", value=0.0, min=-pi / 2.0, max=pi / 2.0)
      params.add("omega", value=3.0, min=0, max=np.inf)
  
      # do fit, here with leastsq model
      result = minimize(fcn2min, params, args=(x, data), epsfcn=1.0e-14)
  
      # assert that the real parameters are found
      for para, val in zip(result.params.values(), [5, 0.025, -0.1, 2]):
          check(para, val)
  
      # assert that the covariance matrix is correct [cf. lmfit v0.9.10]
      cov_x = np.array(
          [
              [
                  1.42428250e-03,
                  9.45395985e-06,
                  -4.33997922e-05,
                  1.07362106e-05,
              ],
              [
                  9.45395985e-06,
                  1.84110424e-07,
                  -2.90588963e-07,
                  7.19107184e-08,
              ],
              [
                  -4.33997922e-05,
                  -2.90588963e-07,
                  9.53427031e-05,
                  -2.37750362e-05,
              ],
              [
                  1.07362106e-05,
                  7.19107184e-08,
                  -2.37750362e-05,
                  9.60952336e-06,
              ],
          ]
      )
      assert_allclose(result.covar, cov_x, rtol=1.0e-3, atol=1.0e-6)
  
      # assert that stderr and correlations are correct [cf. lmfit v0.9.10]
      assert_almost_equal(
          result.params["amp"].stderr, 0.03773967, decimal=4
      )
      assert_almost_equal(
          result.params["decay"].stderr, 4.2908e-04, decimal=4
      )
      assert_almost_equal(
          result.params["shift"].stderr, 0.00976436, decimal=4
      )
      assert_almost_equal(
          result.params["omega"].stderr, 0.00309992, decimal=4
      )
  
      assert_almost_equal(
          result.params["amp"].correl["decay"],
          0.5838166760743324,
          decimal=4,
      )
      assert_almost_equal(
          result.params["amp"].correl["shift"],
          -0.11777303073961824,
          decimal=4,
      )
      assert_almost_equal(
          result.params["amp"].correl["omega"],
          0.09177027400788784,
          decimal=4,
      )
      assert_almost_equal(
          result.params["decay"].correl["shift"],
          -0.0693579417651835,
          decimal=4,
      )
      assert_almost_equal(
          result.params["decay"].correl["omega"],
          0.05406342001021014,
          decimal=4,
      )
      assert_almost_equal(
          result.params["shift"].correl["omega"],
          -0.7854644476455469,
          decimal=4,
      )
  
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 2 for calling a global function with example usage: test_bounded_parameters() and returns: unknown