Exemplo n.º 1
0
def test_adk():
    # Test properties.
    assert ADK(EQ()).stationary
    assert not ADK(Linear()).stationary

    # Test printing.
    assert str(ADK(EQ())) == "EQ()"
    assert str(ADK(EQ()) + ADK(Linear())) == "EQ() + Linear()"
    assert str(ADK(EQ() + Linear())) == "EQ() + Linear()"

    # Test equality.
    assert ADK(EQ()) == ADK(EQ())
    assert ADK(EQ()) != ADK(Linear())

    # Test computation.
    x = B.linspace(0, 5, 10)
    approx(pairwise(ADK(EQ()), x), pairwise(EQ(), x))
    approx(elwise(ADK(EQ()), x), elwise(EQ(), x))

    # Check that the dimensionality resolves to `None`.
    assert dimensionality(EQ()) == 1
    assert dimensionality(ADK(EQ())) is None
Exemplo n.º 2
0
def pairwise(k: MultiOutputKernel, x: B.Numeric, y: FDD):
    return pairwise(k, tuple(p(x) for p in k.ps), (y, ))
Exemplo n.º 3
0
def pairwise(k: MultiOutputKernel, x: FDD, y: B.Numeric):
    return pairwise(k, (x, ), tuple(p(y) for p in k.ps))
Exemplo n.º 4
0
def pairwise(k, x: tuple, y: tuple):
    return B.block(*[[pairwise(k, xi, yi) for yi in y] for xi in x])
Exemplo n.º 5
0
def pairwise(k, x, y: tuple):
    return pairwise(k, (x,), y)
Exemplo n.º 6
0
def pairwise(k, x: tuple, y):
    return pairwise(k, x, (y,))
Exemplo n.º 7
0
def pairwise(k: AmbiguousDimensionalityKernel, x, y):
    return pairwise(k[0], x, y)