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