def test_jsd_pmf5():
    """ Test that JSD fails when more weights than dists are given """
    d1 = [0.5, 0.5, 0.0]
    d2 = [0.0, 0.5, 0.5]
    with pytest.raises(ditException):
        JSD_pmf([d1, d2], [0.1, 0.6, 0.2, 0.1])
def test_jsd_pmf3():
    """ Test the JSD with disjoint distributions """
    d1 = [0.5, 0.5, 0.0, 0.0]
    d2 = [0.0, 0.0, 0.5, 0.5]
    jsd = JSD_pmf([d1, d2])
    assert jsd == pytest.approx(1.0)
def test_jsd_pmf4():
    """ Test the JSD with half-overlapping distributions with weights """
    d1 = [0.5, 0.5, 0.0]
    d2 = [0.0, 0.5, 0.5]
    jsd = JSD_pmf([d1, d2], [0.25, 0.75])
    assert jsd == pytest.approx(0.40563906222956625)
def test_jsd_pmf2():
    """ Test the JSD with half-overlapping distributions """
    d1 = [0.5, 0.5, 0.0]
    d2 = [0.0, 0.5, 0.5]
    jsd = JSD_pmf([d1, d2])
    assert jsd == pytest.approx(0.5)
def test_jsd_pmf1():
    """ Test the JSD of a distribution with itself """
    d1 = [0.5, 0.5]
    jsd = JSD_pmf([d1, d1])
    assert jsd == pytest.approx(0)
def test_jsd_pmf3():
    """ Test the JSD with disjoint distributions """
    d1 = [0.5, 0.5, 0.0, 0.0]
    d2 = [0.0, 0.0, 0.5, 0.5]
    jsd = JSD_pmf([d1, d2])
    assert_almost_equal(jsd, 1.0)
def test_jsd_pmf2():
    """ Test the JSD with half-overlapping distributions """
    d1 = [0.5, 0.5, 0.0]
    d2 = [0.0, 0.5, 0.5]
    jsd = JSD_pmf([d1, d2])
    assert_almost_equal(jsd, 0.5)
def test_jsd_pmf1():
    """ Test the JSD of a distribution with itself """
    d1 = [0.5, 0.5]
    jsd = JSD_pmf([d1, d1])
    assert_almost_equal(jsd, 0)