Exemplo n.º 1
0
def test_init():
    def foo(x, y):
        return x + y

    sampler = Sampler(foo)
    assert len(sampler.domain) == 2
    close(sampler.domain[0], (0.0, 1.0))
    close(sampler.domain[1], (0.0, 1.0))

    (x, y), z = sampler.sample(100)
    close(x + y, z)
    assert max(x) < 1.0
    assert min(x) > 0.0
    assert min(y) > 0.0
    assert max(x) < 1.0

    a = np.arange(0, 100).reshape((10, 10))

    sampler = Sampler(a)
    assert len(sampler.domain) == 2
    close(sampler.domain[0], (0, 10))
    close(sampler.domain[1], (0, 10))

    (x, y), z = sampler.sample(100)
    print(x)
    print(y)
    print(z)
    assert np.max(x) <= 1.0
    assert np.min(x) >= 0.0
    assert np.min(y) >= 0.0
    assert np.max(x) <= 1.0
Exemplo n.º 2
0
def test_mutinf_knn():
    close(mutinf(3, X, Y, method='knn'), TRUE_MUTINF, atol=.01, rtol=.2)
Exemplo n.º 3
0
def test_ncmutinf_doanes_rule():
    close(ncmutinf(None, a, b, c, method='grassberger'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.4)
Exemplo n.º 4
0
def test_ncmutinf_chaowangjost():
    close(ncmutinf(8, a, b, c, method='chaowangjost'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.2)
Exemplo n.º 5
0
def test_entropy_naive():
    close(entropy(8, RNG, None, X), TRUE_ENTROPY, rtol=.2)
Exemplo n.º 6
0
def test_entropy_grassberger():
    close(entropy(8, RNG, 'grassberger', X), TRUE_ENTROPY, rtol=.2)
Exemplo n.º 7
0
def test_entropy_knn():
    close(entropy(3, [None], 'knn', X), TRUE_ENTROPY, rtol=.2)
Exemplo n.º 8
0
def test_mutinf_naive():
    close(mutinf(8, X, Y, method=None), TRUE_MUTINF, atol=.01, rtol=.2)
Exemplo n.º 9
0
def test_ncmutinf_chaowangjost():
    close(ncmutinf(8, a, b, c, method='chaowangjost'), TRUE_NCMUTINF, atol=.05,
          rtol=.2)
Exemplo n.º 10
0
def test_ncmutinf_knn():
    close(ncmutinf(3, a, b, c, method='knn'), TRUE_NCMUTINF, atol=.05, rtol=.2)
Exemplo n.º 11
0
def test_mutinf_naive():
    close(mutinf(8, X, Y, method=None), TRUE_MUTINF, atol=.01, rtol=.2)
Exemplo n.º 12
0
def test_mutinf_doanes_rule():
    close(mutinf(None, X, Y, method='grassberger'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Exemplo n.º 13
0
def test_mutinf_grassberger():
    close(mutinf(8, X, Y, method='grassberger'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Exemplo n.º 14
0
def test_mutinf_chaowangjost():
    close(mutinf(8, X, Y, method='chaowangjost'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Exemplo n.º 15
0
def test_mutinf_grassberger():
    close(mutinf(8, X, Y, method='grassberger'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Exemplo n.º 16
0
def test_mutinf_doanes_rule():
    close(mutinf(None, X, Y, method='grassberger'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Exemplo n.º 17
0
def test_ncmutinf_grassberger():
    close(ncmutinf(8, a, b, c, method='grassberger'), TRUE_NCMUTINF, atol=.05,
          rtol=.2)
Exemplo n.º 18
0
def test_entropy_kde():
    close(entropy(8, RNG, 'kde', X), TRUE_ENTROPY, rtol=.2)
Exemplo n.º 19
0
def test_ncmutinf_doanes_rule():
    close(ncmutinf(None, a, b, c, method='grassberger'), TRUE_NCMUTINF,
          atol=.05, rtol=.4)
Exemplo n.º 20
0
def test_entropy_chaowangjost():
    close(entropy(8, RNG, 'chaowangjost', X), TRUE_ENTROPY, rtol=.2)
Exemplo n.º 21
0
def test_ncmutinf_naive():
    close(ncmutinf(8, a, b, c, method=None), TRUE_NCMUTINF, atol=.05, rtol=.2)
Exemplo n.º 22
0
def test_entropy_doanes_rule():
    close(entropy(None, RNG, 'grassberger', X), TRUE_ENTROPY, atol=2., rtol=.2)
Exemplo n.º 23
0
def test_mutinf_kde():
    close(mutinf(8, X, Y, method='kde'), TRUE_MUTINF, atol=.01, rtol=.2)
Exemplo n.º 24
0
def test_ncmutinf_knn():
    close(ncmutinf(3, a, b, c, method='knn'), TRUE_NCMUTINF, atol=.05, rtol=.2)
Exemplo n.º 25
0
def test_mutinf_knn():
    close(mutinf(3, X, Y, method='knn'), TRUE_MUTINF, atol=.01, rtol=.2)
Exemplo n.º 26
0
def test_ncmutinf_grassberger():
    close(ncmutinf(8, a, b, c, method='grassberger'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.2)
Exemplo n.º 27
0
def test_mutinf_chaowangjost():
    close(mutinf(8, X, Y, method='chaowangjost'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Exemplo n.º 28
0
def test_ncmutinf_naive():
    close(ncmutinf(8, a, b, c, method=None), TRUE_NCMUTINF, atol=.05, rtol=.2)
Exemplo n.º 29
0
def test_mutinf_kde():
    close(mutinf(8, X, Y, method='kde'), TRUE_MUTINF, atol=.01, rtol=.2)