MCPcopy Create free account
hub / github.com/PythonOT/POT / test_kl_div

Function test_kl_div

test/test_utils.py:693–706  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

691
692
693def test_kl_div(nx):
694 n = 10
695 rng = np.random.RandomState(0)
696 # test on non-negative tensors
697 x = rng.randn(n)
698 x = x - x.min() + 1e-5
699 y = rng.randn(n)
700 y = y - y.min() + 1e-5
701 xb = nx.from_numpy(x)
702 yb = nx.from_numpy(y)
703 kl = nx.kl_div(xb, yb)
704 kl_mass = nx.kl_div(xb, yb, True)
705 recovered_kl = kl_mass - nx.sum(yb - xb)
706 np.testing.assert_allclose(kl, recovered_kl)
707
708
709def test_exp_bures(nx):

Callers

nothing calls this directly

Calls 5

from_numpyMethod · 0.80
randnMethod · 0.45
minMethod · 0.45
kl_divMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected