code: def test_norms_consistent(case):
      # test that norm methods are consistent with each other
      ncls, args = case
      norm = ncls(*args)
      x = np.array([-9, -6, -2, -1, 0, 1, 2, 6, 9], dtype=float)
  
      weights = norm.weights(x)
      rho = norm.rho(x)  # not used
      psi = norm.psi(x)
      psi_deriv = norm.psi_deriv(x)
  
      # check location and u-shape of rho
      assert_allclose(rho[4], 0, atol=1e-12)
      assert np.all(np.diff(rho[4:]) >= 0)
      assert np.all(np.diff(rho[:4]) <= 0)
  
      # avoid zero division nan:
      assert_allclose(
          weights, (psi + 1e-50) / (x + 1e-50), rtol=1e-6, atol=1e-8
      )
      psid = _approx_fprime_scalar(x, norm.rho)
      assert_allclose(psi, psid, rtol=1e-6, atol=1e-6)
      psidd = _approx_fprime_scalar(x, norm.psi)
      assert_allclose(psi_deriv, psidd, rtol=1e-6, atol=1e-8)
  
file_path: statsmodels/statsmodels/robust/tests/test_norms.py
imports: import pytest
  import numpy
  from numpy.testing import assert_allclose
  from statsmodels.robust import norms
  from statsmodels.tools.numdiff import _approx_fprime_scalar
  from .results import results_norms
label_desc: Use image node_id 2 for calling a global function with example usage: test_norms_consistent(case) without return types