code: def test_linear_gen():
      x = np.linspace(-10, 10, 200)
      c = -0.5
      xlim = [-2.4, 6.0]
      # replaced with from astroML.stats.random import linear
      # linear = linear_gen(name="linear", shapes="a, b, c")
      y = linear.pdf(x, xlim[0], xlim[1], c)
      zeros = np.zeros(len(y))
  
      # Test that the function is zero outside of defined limits
      assert_array_equal(y[x < xlim[0]], zeros[x < xlim[0]])
      assert_array_equal(y[x > xlim[1]], zeros[x > xlim[1]])
      inlims = (x < xlim[1]) & (x > xlim[0])
      d = 1.0 / (xlim[1] - xlim[0]) - 0.5 * c * (xlim[1] + xlim[0])
      inlims = (x < xlim[1]) & (x > xlim[0])
  
      # Test that within defined limits, function is linear
      assert_array_equal(y[inlims], c * x[inlims] + d)
  
      # Test that the PDF integrates to about 1
      dx = x[1] - x[0]
      integral = np.sum(y * dx)
      assert np.round(integral, 1) == 1
  
file_path: astroML/astroML/stats/tests/test_stats.py
imports: import pytest
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_allclose
  from astroML.stats import mean_sigma, median_sigmaG, sigmaG, fit_bivariate_normal
  from astroML.stats.random import bivariate_normal, trunc_exp, linear
label_desc: Use image node_id 8 for calling a global function with example usage: test_linear_gen() without return types