code: def test_cont_fit(distname, arg, method):
      if distname in failing_fits[method]:
          # Skip failing fits unless overridden
          try:
              xfail = not int(os.environ["SCIPY_XFAIL"])
          except Exception:
              xfail = True
          if xfail:
              msg = "Fitting %s doesn't work reliably yet" % distname
              msg += (
                  " [Set environment variable SCIPY_XFAIL=1 to run this"
                  " test nevertheless.]"
              )
              pytest.xfail(msg)
  
      distfn = getattr(stats, distname)
  
      truearg = np.hstack([arg, [0.0, 1.0]])
      diffthreshold = np.max(
          np.vstack(
              [
                  truearg * thresh_percent,
                  np.full(distfn.numargs + 2, thresh_min),
              ]
          ),
          0,
      )
  
      for fit_size in fit_sizes:
          # Note that if a fit succeeds, the other fit_sizes are skipped
          np.random.seed(1234)
  
          with np.errstate(all="ignore"):
              rvs = distfn.rvs(size=fit_size, *arg)
              est = distfn.fit(
                  rvs, method=method
              )  # start with default values
  
          diff = est - truearg
  
          # threshold for location
          diffthreshold[-2] = np.max(
              [np.abs(rvs.mean()) * thresh_percent, thresh_min]
          )
  
          if np.any(np.isnan(est)):
              raise AssertionError("nan returned in fit")
          else:
              if np.all(np.abs(diff) <= diffthreshold):
                  break
      else:
          txt = "parameter: %s\n" % str(truearg)
          txt += "estimated: %s\n" % str(est)
          txt += "diff     : %s\n" % str(diff)
          raise AssertionError(
              "fit not very good in %s\n" % distfn.name + txt
          )
  
file_path: catboost/contrib/python/scipy/py3/scipy/stats/tests/test_fit.py
imports: import os
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from scipy import stats
  from .test_continuous_basic import distcont
label_desc: Use image node_id 2 for calling a global function with example usage: test_cont_fit(distname, arg, method) without return types