예제 #1
0
def test_sample1():
    # Basic sample
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d)
    assert x == '101'

    # with log dist
    dit.math.prng.seed(0)
    d.set_base(3.5)
    x = module.sample(d)
    assert x == '101'
예제 #2
0
def test_sample1():
    # Basic sample
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d)
    assert_equal(x, '101')

    # with log dist
    dit.math.prng.seed(0)
    d.set_base(3.5)
    x = module.sample(d)
    assert_equal(x, '101')
예제 #3
0
def test_sample6():
    # Not enough rands
    d = dit.example_dists.Xor()
    with pytest.raises(ditException):
        module.sample(d, 5, rand=[.1] * 3)
예제 #4
0
def test_sample5():
    # Bad prng
    d = dit.example_dists.Xor()
    with pytest.raises(ditException):
        module.sample(d, prng=3)
예제 #5
0
def test_sample4():
    # More than one random number
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d, 6)
    assert x == ['101', '101', '101', '101', '011', '101']
예제 #6
0
def test_sample3():
    # Specified rand number
    d = dit.example_dists.Xor()
    x = module.sample(d, rand=.3)
    assert x == '011'
예제 #7
0
def test_sample2():
    # Specified prng
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d, prng=dit.math.prng)
    assert x == '101'
예제 #8
0
def test_sample4():
    # More than one random number
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d, 6)
    assert_equal(x, ['101', '101', '101', '101', '011', '101'])
예제 #9
0
def test_sample3():
    # Specified rand number
    d = dit.example_dists.Xor()
    x = module.sample(d, rand=.3)
    assert_equal(x, '011')
예제 #10
0
def test_sample2():
    # Specified prng
    d = dit.example_dists.Xor()
    dit.math.prng.seed(0)
    x = module.sample(d, prng=dit.math.prng)
    assert_equal(x, '101')