def test_kind(): assert Kind[1] == Kind[1] assert Kind[1] != Kind[2] assert Kind[1](1).get() == 1 assert Kind[2](1, 2).get() == (1, 2) Kind2 = kind() assert Kind2[1] != Kind[1] assert Kind[1] == Kind[1] assert Kind2[1] == Kind2[1] # Test providing a superclass, where the default should be `object`. class SuperClass: pass Kind3 = kind(SuperClass) assert issubclass(Kind3[1], SuperClass) assert not issubclass(Kind2[1], SuperClass) assert issubclass(Kind2[1], object)
def test_kind(): assert Kind(1) == Kind(1) assert Kind(1) != Kind(2) assert Kind(1)(1).get() == 1 assert Kind(2)(1, 2).get() == (1, 2) Kind2 = kind() assert Kind2(1) != Kind(1) assert Kind(1) == Kind(1) assert Kind2(1) == Kind2(1) # Test providing a superclass, where the default should be `object`. class SuperClass: pass Kind3 = kind(SuperClass) assert issubclass(Kind3(1), SuperClass) assert not issubclass(Kind2(1), SuperClass) assert issubclass(Kind2(1), object)
self._xs = xs def get(self): """Get the wrapped input.""" return self._xs[0] if len(self._xs) == 1 else self._xs @parametric class Component(Input): """A particular component. This is a parametric type. """ class MultiInput(Input): """Multiple inputs.""" def get(self): return self._xs class Unique(Input): """One cannot learn about noise at these inputs""" Observed = Component('observed') #: Observed points Latent = Component('latent') #: Latent points #: A generic parametric type used to specify locations at a particular process. At = kind(Input)