code: def check_height_fwhm(x, y, lineshape, model):
      """Check height and fwhm parameters."""
      pars = model.guess(y, x=x)
      out = model.fit(y, pars, x=x)
  
      # account for functions whose centers are not mu
      mu = out.params["center"].value
      if lineshape is lineshapes.lognormal:
          cen = np.exp(mu - out.params["sigma"] ** 2)
      elif lineshape is lineshapes.pearson4:
          cen = out.params["position"]
      else:
          cen = mu
  
      # get arguments for lineshape
      sig = inspect.signature(lineshape)
      args = {
          key: out.best_values[key]
          for key in sig.parameters.keys()
          if key != "x"
      }
  
      # output format for assertion errors
      fmt = (
          "Program calculated values and real values do not match!\n"
          "{:^20s}{:^20s}{:^20s}{:^20s}\n"
          "{:^20s}{:^20f}{:^20f}{:^20f}"
      )
  
      if "height" in out.params:
          height_pro = out.params["height"].value
          height_act = lineshape(cen, **args)
          diff = height_act - height_pro
  
          assert abs(diff) < 0.001, fmt.format(
              model._name,
              "Actual",
              "program",
              "Difference",
              "Height",
              height_act,
              height_pro,
              diff,
          )
  
          if "fwhm" in out.params:
              fwhm_pro = out.params["fwhm"].value
              func = lambda x: lineshape(x, **args) - 0.5 * height_act
              ret = fsolve(
                  func, [cen - fwhm_pro / 4, cen + fwhm_pro / 2]
              )
              fwhm_act = ret[1] - ret[0]
              diff = fwhm_act - fwhm_pro
  
              assert abs(diff) < 0.5, fmt.format(
                  model._name,
                  "Actual",
                  "program",
                  "Difference",
                  "FWHM",
                  fwhm_act,
                  fwhm_pro,
                  diff,
              )
  
file_path: lmfit-py/tests/test_builtin_models.py
imports: import inspect
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from scipy.optimize import fsolve
  from lmfit import lineshapes, models
  from lmfit.models import GaussianModel
label_desc: Use image node_id 1 for calling a global function with example usage: check_height_fwhm(x, y, lineshape, model) without return types