def test_shorthands(): model = Graph() p = GP(EQ(), graph=model) # Construct a normal distribution that serves as in input. x = p(1) assert isinstance(x, At) assert type_parameter(x) is p assert x.get() == 1 assert str(p(x)) == '{}({})'.format(str(p), str(x)) assert repr(p(x)) == '{}({})'.format(repr(p), repr(x)) # Construct a normal distribution that does not serve as an input. x = Normal(np.ones((1, 1))) with pytest.raises(RuntimeError): type_parameter(x) with pytest.raises(RuntimeError): x.get() with pytest.raises(RuntimeError): p | (x, 1) # Test shorthands for stretching and selection. p = GP(EQ(), graph=Graph()) assert str(p > 2) == str(p.stretch(2)) assert str(p[0]) == str(p.select(0))
def test_shorthands(): model = Graph() p = GP(EQ(), graph=model) # Construct a normal distribution that serves as in input. x = p(1) yield assert_instance, x, At yield ok, type_parameter(x) is p yield eq, x.get(), 1 yield eq, str(p(x)), '{}({})'.format(str(p), str(x)) yield eq, repr(p(x)), '{}({})'.format(repr(p), repr(x)) # Construct a normal distribution that does not serve as an input. x = Normal(np.ones((1, 1))) yield raises, RuntimeError, lambda: type_parameter(x) yield raises, RuntimeError, lambda: x.get() yield raises, RuntimeError, lambda: p | (x, 1) # Test shorthands for stretching and selection. p = GP(EQ(), graph=Graph()) yield eq, str(p > 2), str(p.stretch(2)) yield eq, str(p[0]), str(p.select(0))