def _test_generic_return_generic(self, method, pdf_method, mytype, arraytype, *args): a_result = method(*args) # flag = type(a_result) == mytype # assert(flag) if pdf_method: tmp = (a_result,) + args test2 = 0 try: p = pdf_method(*tmp) test2 = 1 finally: if test2 == 0: print "called pdf method", pdf_method, print "with args", tmp assert isfloat(p) tmp = args + (10,) da = method(*tmp) array_check(da, arraytype, (10,)) if pdf_method: tmp = (da,) + args pa = pdf_method(*tmp) array_check(pa, Float, (10,))
def _test_generic_return_generic(self, method, pdf_method, mytype, arraytype, *args): a_result = method(*args) #flag = type(a_result) == mytype #assert(flag) if pdf_method: tmp = (a_result, ) + args test2 = 0 try: p = pdf_method(*tmp) test2 = 1 finally: if test2 == 0: print("called pdf method", pdf_method) print("with args", tmp) assert (isfloat(p)) tmp = args + (10, ) da = method(*tmp) array_check(da, arraytype, (10, )) if pdf_method: tmp = (da, ) + args pa = pdf_method(*tmp) array_check(pa, Float, (10, ))
def test_dirichlet(self): a = Numeric.arange(10) * 0.1 + 0.1 d = self.rng.dirichlet(a) array_check(d, Float, (a.shape[0],)) ra = Numeric.reshape(a, (a.shape[0], -1)) ra = Numeric.transpose(ra) p = rngmodule.dirichlet_pdf(d, ra) d = self.rng.dirichlet(a, 100) array_check(d, Float, (100, a.shape[0]))
def test_dirichlet(self): a = numx.arange(10) * .1 + .1 d = self.rng.dirichlet(a) array_check(d, Float, (a.shape[0], )) ra = numx.reshape(a, (a.shape[0], -1)) ra = numx.transpose(ra) p = rngmodule.dirichlet_pdf(d, ra) d = self.rng.dirichlet(a, 100) array_check(d, Float, (100, a.shape[0]))
def _test_nd_return_one(self, method, pdf_method, n, *args): test = 0 try: d = method(*args) assert len(d) == n for i in d: assert isfloat(i) if pdf_method: p = apply(pdf_method, tuple(d) + args) assert isfloat(p) da = apply(method, args + (10,)) array_check(da, Float, (10, n)) if pdf_method: x = da[:, 0] y = da[:, 1] pa = apply(pdf_method, (x, y) + args) array_check(da, Float, (10, 2)) test = 1 finally: if test == 0: print "I was testing ", method, "with args", args
def _test_nd_return_one(self, method, pdf_method, n, *args): test = 0 try: d = method(*args) assert (len(d) == n) for i in d: assert (isfloat(i)) if pdf_method: p = pdf_method(*(tuple(d) + args)) assert (isfloat(p)) da = method(*(args + (10, ))) array_check(da, Float, (10, n)) if pdf_method: x = da[:, 0] y = da[:, 1] pa = pdf_method(*((x, y) + args)) array_check(da, Float, (10, 2)) test = 1 finally: if test == 0: print("I was testing ", method, "with args", args)
def __testreturn(self, array, dim0): test = 0 array_check(array, Float, (dim0, self._dim))