Example #1
0
def test_expand_corrmats_same():
    sub_corrmat = _get_corrmat(bo)
    np.fill_diagonal(sub_corrmat, 0)  # <- possible failpoint
    sub_corrmat_z = _r2z(sub_corrmat)
    weights = _rbf(test_model.locs, bo.locs)

    expanded_num_p, expanded_denom_p = _expand_corrmat_predict(sub_corrmat_z, weights)
    model_corrmat_p = np.divide(expanded_num_p, expanded_denom_p)
    expanded_num_f, expanded_denom_f = _expand_corrmat_predict(sub_corrmat_z, weights)
    model_corrmat_f = np.divide(expanded_num_f, expanded_denom_f)

    np.fill_diagonal(model_corrmat_f, 0)
    np.fill_diagonal(model_corrmat_p, 0)

    s = test_model.locs.shape[0] - bo.locs.shape[0]

    Kba_p = model_corrmat_p[:s, s:]
    Kba_f = model_corrmat_f[:s, s:]
    Kaa_p = model_corrmat_p[s:, s:]
    Kaa_f = model_corrmat_f[s:, s:]

    assert isinstance(Kaa_p, np.ndarray)
    assert isinstance(Kaa_f, np.ndarray)
    assert np.allclose(Kaa_p, Kaa_f, equal_nan=True)
    assert np.allclose(Kba_p, Kba_f, equal_nan=True)
Example #2
0
def test_expand_corrmat_predict():
    sub_corrmat = _get_corrmat(bo)
    np.fill_diagonal(sub_corrmat, 0)
    sub_corrmat = _r2z(sub_corrmat)
    weights = _rbf(test_model.locs, bo.locs)
    expanded_num_p, expanded_denom_p = _expand_corrmat_predict(sub_corrmat, weights)

    assert isinstance(expanded_num_p, np.ndarray)
    assert isinstance(expanded_denom_p, np.ndarray)
    assert np.shape(expanded_num_p)[0] == test_model.locs.shape[0]
Example #3
0
def test_array_r2z():
    r = np.array([.1, .2, .3])
    test_val = 0.5 * (np.log(1 + r) - np.log(1 - r))
    test_fun = _r2z(r)
    assert isinstance(test_fun, np.ndarray)
    assert np.allclose(test_val, test_fun)
Example #4
0
def test_int_r2z():
    r = .1
    test_val = 0.5 * (np.log(1 + r) - np.log(1 - r))
    test_fun = _r2z(r)
    assert isinstance(test_fun, (float, int))
    assert test_val == test_fun
Example #5
0
def _r2z_z2r():
    z = np.array([1, 2, 3])
    test_fun = _r2z(_z2r(z))
    assert isinstance(test_fun, (int, np.ndarray))
    assert z == test_fun