code: def test_univariate_kde_sampler():
      feat1 = np.random.normal(size=100)
      feat2 = np.random.randint(0, 2, size=100)
      X = np.array([feat1, feat2]).T
  
      s = UnivariateKernelDensitySampler(random_state=42)
      s.fit(X)
  
      # second feature is categorical, it should use a small bandwidth
      assert np.isclose(s.kdes_[1].bandwidth, 1e-6)
  
      # check sampling results
      samples, sims = s.sample_near([0.1, 1], n_samples=1000)
  
      feat1_sampled = samples[:, 0]
      feat2_sampled = samples[:, 1]
  
      _isclose = partial(np.isclose, atol=1e-5)
  
      # feat2 should have both 0 and 1 values, and it should have more 1 values
      # because document has 1 as a second feature
      zeros = _isclose(feat2_sampled, 0)
      ones = _isclose(feat2_sampled, 1)
      assert (zeros | ones).sum() == 1000
      assert 0.5 < feat2_sampled.mean() < 0.9
      assert zeros.sum() > 100
      assert ones.sum() > 500
  
      # feat1 should be centered around zero
      assert -1 < feat1_sampled.mean() < 1
  
file_path: eli5/tests/test_samplers.py
imports: from functools import partial
  import numpy
  import pytest
  from hypothesis import given
  from hypothesis.strategies import integers, text
  from eli5.lime.samplers import MaskingTextSampler, MaskingTextSamplers, UnivariateKernelDensitySampler, MultivariateKernelDensitySampler
  from sklearn.neighbors import KernelDensity
label_desc: Use image node_id 7 for calling a global function with example usage: test_univariate_kde_sampler() without return types