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