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
def pairwise(k: MultiOutputKernel, x: B.Numeric, y: FDD): return pairwise(k, tuple(p(x) for p in k.ps), (y, ))
def pairwise(k: MultiOutputKernel, x: FDD, y: B.Numeric): return pairwise(k, (x, ), tuple(p(y) for p in k.ps))
def pairwise(k, x: tuple, y: tuple): return B.block(*[[pairwise(k, xi, yi) for yi in y] for xi in x])
def pairwise(k, x, y: tuple): return pairwise(k, (x,), y)
def pairwise(k, x: tuple, y): return pairwise(k, x, (y,))
def pairwise(k: AmbiguousDimensionalityKernel, x, y): return pairwise(k[0], x, y)