MCPcopy Index your code
hub / github.com/python/cpython / test_kde_kernel_specs

Method test_kde_kernel_specs

Lib/test/test_statistics.py:2436–2451  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2434 self.assertGreater(f_hat(100), 0.0)
2435
2436 def test_kde_kernel_specs(self):
2437 # White-box test for the kernel formulas in isolation from
2438 # their downstream use in kde() and kde_random()
2439 kernel_specs = statistics._kernel_specs
2440
2441 # Verify that cdf / invcdf will round trip
2442 xarr = [i/100 for i in range(-100, 101)]
2443 parr = [i/1000 + 5/10000 for i in range(1000)]
2444 for kernel, spec in kernel_specs.items():
2445 cdf = spec['cdf']
2446 invcdf = spec['invcdf']
2447 with self.subTest(kernel=kernel):
2448 for x in xarr:
2449 self.assertAlmostEqual(invcdf(cdf(x)), x, places=6)
2450 for p in parr:
2451 self.assertAlmostEqual(cdf(invcdf(p)), p, places=11)
2452
2453 @support.requires_resource('cpu')
2454 def test_kde_random(self):

Callers

nothing calls this directly

Calls 4

cdfFunction · 0.85
itemsMethod · 0.45
subTestMethod · 0.45
assertAlmostEqualMethod · 0.45

Tested by

no test coverage detected