Esempio 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
Esempio n. 2
0
def elwise(k: MultiOutputKernel, x: B.Numeric, y: B.Numeric):
    return elwise(k, tuple(p(x) for p in k.ps), tuple(p(y) for p in k.ps))
Esempio n. 3
0
def elwise(k, x, y: tuple):
    return elwise(k, (x,), y)
Esempio n. 4
0
def elwise(k, x: tuple, y):
    return elwise(k, x, (y,))
Esempio n. 5
0
def elwise(k, x: tuple, y: tuple):
    if len(x) != len(y):
        raise ValueError('"elwise" must be called with similarly sized tuples.')
    return B.concat(*[elwise(k, xi, yi) for xi, yi in zip(x, y)], axis=-2)
Esempio n. 6
0
def elwise(k: AmbiguousDimensionalityKernel, x, y):
    return elwise(k[0], x, y)