code: def test_gaussian1d():
      x = np.linspace(-6, 10, 1000)
      means = np.array([-1.5, 0.0, 2.3])
      sigmas = np.array([1, 0.25, 3.8])
      weights = np.array([1, 1, 1])
  
      gauss = GaussianMixture1D(
          means=means, sigmas=sigmas, weights=weights
      )
      y = gauss.pdf(x)
  
      # Check whether sampling works
      gauss.sample(10)
  
      dx = x[1] - x[0]
      integral = np.sum(y * dx)
  
      assert_allclose(integral, 1.0, atol=0.02)
  
imports: import pytest
  import numpy
  from numpy.testing import assert_allclose
  from scipy.stats import norm
  from astroML.density_estimation import KNeighborsDensity, GaussianMixture1D
label_desc: Use image node_id 2 for calling a global function with example usage: test_gaussian1d() without return types