Esempio 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
Esempio n. 2
0
def test_mutinf_knn():
    close(mutinf(3, X, Y, method='knn'), TRUE_MUTINF, atol=.01, rtol=.2)
Esempio n. 3
0
def test_ncmutinf_doanes_rule():
    close(ncmutinf(None, a, b, c, method='grassberger'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.4)
Esempio n. 4
0
def test_ncmutinf_chaowangjost():
    close(ncmutinf(8, a, b, c, method='chaowangjost'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.2)
Esempio n. 5
0
def test_entropy_naive():
    close(entropy(8, RNG, None, X), TRUE_ENTROPY, rtol=.2)
Esempio n. 6
0
def test_entropy_grassberger():
    close(entropy(8, RNG, 'grassberger', X), TRUE_ENTROPY, rtol=.2)
Esempio n. 7
0
def test_entropy_knn():
    close(entropy(3, [None], 'knn', X), TRUE_ENTROPY, rtol=.2)
Esempio n. 8
0
def test_mutinf_naive():
    close(mutinf(8, X, Y, method=None), TRUE_MUTINF, atol=.01, rtol=.2)
Esempio n. 9
0
def test_ncmutinf_chaowangjost():
    close(ncmutinf(8, a, b, c, method='chaowangjost'), TRUE_NCMUTINF, atol=.05,
          rtol=.2)
Esempio n. 10
0
def test_ncmutinf_knn():
    close(ncmutinf(3, a, b, c, method='knn'), TRUE_NCMUTINF, atol=.05, rtol=.2)
Esempio n. 11
0
def test_mutinf_naive():
    close(mutinf(8, X, Y, method=None), TRUE_MUTINF, atol=.01, rtol=.2)
Esempio n. 12
0
def test_mutinf_doanes_rule():
    close(mutinf(None, X, Y, method='grassberger'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Esempio n. 13
0
def test_mutinf_grassberger():
    close(mutinf(8, X, Y, method='grassberger'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Esempio n. 14
0
def test_mutinf_chaowangjost():
    close(mutinf(8, X, Y, method='chaowangjost'),
          TRUE_MUTINF,
          atol=.01,
          rtol=.2)
Esempio n. 15
0
def test_mutinf_grassberger():
    close(mutinf(8, X, Y, method='grassberger'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Esempio n. 16
0
def test_mutinf_doanes_rule():
    close(mutinf(None, X, Y, method='grassberger'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Esempio n. 17
0
def test_ncmutinf_grassberger():
    close(ncmutinf(8, a, b, c, method='grassberger'), TRUE_NCMUTINF, atol=.05,
          rtol=.2)
Esempio n. 18
0
def test_entropy_kde():
    close(entropy(8, RNG, 'kde', X), TRUE_ENTROPY, rtol=.2)
Esempio n. 19
0
def test_ncmutinf_doanes_rule():
    close(ncmutinf(None, a, b, c, method='grassberger'), TRUE_NCMUTINF,
          atol=.05, rtol=.4)
Esempio n. 20
0
def test_entropy_chaowangjost():
    close(entropy(8, RNG, 'chaowangjost', X), TRUE_ENTROPY, rtol=.2)
Esempio n. 21
0
def test_ncmutinf_naive():
    close(ncmutinf(8, a, b, c, method=None), TRUE_NCMUTINF, atol=.05, rtol=.2)
Esempio n. 22
0
def test_entropy_doanes_rule():
    close(entropy(None, RNG, 'grassberger', X), TRUE_ENTROPY, atol=2., rtol=.2)
Esempio n. 23
0
def test_mutinf_kde():
    close(mutinf(8, X, Y, method='kde'), TRUE_MUTINF, atol=.01, rtol=.2)
Esempio n. 24
0
def test_ncmutinf_knn():
    close(ncmutinf(3, a, b, c, method='knn'), TRUE_NCMUTINF, atol=.05, rtol=.2)
Esempio n. 25
0
def test_mutinf_knn():
    close(mutinf(3, X, Y, method='knn'), TRUE_MUTINF, atol=.01, rtol=.2)
Esempio n. 26
0
def test_ncmutinf_grassberger():
    close(ncmutinf(8, a, b, c, method='grassberger'),
          TRUE_NCMUTINF,
          atol=.05,
          rtol=.2)
Esempio n. 27
0
def test_mutinf_chaowangjost():
    close(mutinf(8, X, Y, method='chaowangjost'), TRUE_MUTINF, atol=.01,
          rtol=.2)
Esempio n. 28
0
def test_ncmutinf_naive():
    close(ncmutinf(8, a, b, c, method=None), TRUE_NCMUTINF, atol=.05, rtol=.2)
Esempio n. 29
0
def test_mutinf_kde():
    close(mutinf(8, X, Y, method='kde'), TRUE_MUTINF, atol=.01, rtol=.2)