Exemplo n.º 1
0
def test_ProductPSpace():
    X = Normal('X', 0, 1)
    Y = Normal('Y', 0, 1)
    px = X.pspace
    py = Y.pspace
    assert pspace(X + Y) == ProductPSpace(px, py)
    assert pspace(X + Y) == ProductPSpace(py, px)
Exemplo n.º 2
0
def test_pspace():
    X, Y = Normal('X', 0, 1), Normal('Y', 0, 1)

    pytest.raises(ValueError, lambda: pspace(5 + 3))
    pytest.raises(ValueError, lambda: pspace(x < 1))
    assert pspace(X) == X.pspace
    assert pspace(2*X + 1) == X.pspace
    assert pspace(2*X + Y) == ProductPSpace(Y.pspace, X.pspace)
Exemplo n.º 3
0
def test_ProductPSpace():
    X = Normal('X', 0, 1)
    Y = Normal('Y', 0, 1)
    px = X.pspace
    py = Y.pspace
    assert pspace(X + Y) == ProductPSpace(px, py)
    assert pspace(X + Y) == ProductPSpace(py, px)

    X = Die('X', 2)
    Y = Die('Y', 2)

    assert (pspace(X + Y).density ==
            Dict((frozenset({('X', 1), ('Y', 2)}), Rational(1, 4)),
                 (frozenset({('X', 1), ('Y', 1)}), Rational(1, 4)),
                 (frozenset({('X', 2), ('Y', 1)}), Rational(1, 4)),
                 (frozenset({('X', 2), ('Y', 2)}), Rational(1, 4))))
    d = pspace(X + Y).domain
    assert ((X.symbol, 1), (Y.symbol, 2)) in d
    assert ((X.symbol, 0), (Y.symbol, 2)) not in d

    Z = Die('Z', 2)
    d1 = pspace(X + Y).domain
    assert ProductDomain(d1, Z.pspace.domain) == pspace(X + Y + Z).domain