def test_mixture_distribution2(): # Test when pmfs are different lengths. d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['A', 'B'], [1, 0], sort=True, trim=True) # Fails when it checks that all pmfs have the same length. with pytest.raises(ValueError): dit.mixture_distribution2([d, d2], [0.5, 0.5])
def test_mixture_distribution_weights(): d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['A', 'B'], [1, 0]) with pytest.raises(ditException): dit.mixture_distribution([d, d2], [1]) with pytest.raises(ditException): dit.mixture_distribution2([d, d2], [1])
def test_mixture_distribution2(): # Test when pmfs are different lengths. d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['A', 'B'], [1, 0], sort=True, trim=True) # Fails when it checks that all pmfs have the same length. with pytest.raises(ValueError): dit.mixture_distribution2([d, d2], [0.5, 0.5])
def test_mixture_distribution_weights(): d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['A', 'B'], [1, 0]) with pytest.raises(ditException): dit.mixture_distribution([d, d2], [1]) with pytest.raises(ditException): dit.mixture_distribution2([d, d2], [1])
def test_mixture_distribution4(): # Sample spaces are compatible. # But pmfs have a different lengths and orders. d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['B', 'A'], [1, 0], sort=False, trim=False, sparse=True) d2.make_sparse(trim=True) pmf = np.array([0.25, 0.75]) d3 = dit.mixture_distribution([d, d2], [0.5, 0.5]) assert np.allclose(pmf, d3.pmf) with pytest.raises(ValueError): dit.mixture_distribution2([d, d2], [0.5, 0.5])
def test_mixture_distribution3(): # Sample spaces are compatible. # But pmfs have a different order. d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['B', 'A'], [1, 0], sort=False, trim=False, sparse=False) pmf = np.array([0.25, 0.75]) d3 = dit.mixture_distribution([d, d2], [0.5, 0.5]) assert_true(np.allclose(pmf, d3.pmf)) d3 = dit.mixture_distribution2([d, d2], [0.5, 0.5]) assert_false(np.allclose(pmf, d3.pmf))
def test_mixture_distribution3(): # Sample spaces are compatible. # But pmfs have a different order. d = dit.Distribution(['A', 'B'], [0.5, 0.5]) d2 = dit.Distribution(['B', 'A'], [1, 0], sort=False, trim=False, sparse=False) pmf = np.array([0.25, 0.75]) d3 = dit.mixture_distribution([d, d2], [0.5, 0.5]) assert np.allclose(pmf, d3.pmf) d3 = dit.mixture_distribution2([d, d2], [0.5, 0.5]) assert not np.allclose(pmf, d3.pmf)