def test03(self): """Testing with only dynd arrays""" a, b = np.arange(self.N), np.arange(1, self.N+1) c = nd.array(a) d = nd.array(b) cr = blaze._elwise_eval("c * d", vm=self.vm) nr = a * b assert_array_equal(cr[:], nr, "eval does not work correctly")
def test04(self): """Testing with a mix of blaze, numpy and dynd arrays""" a, b = np.arange(self.N), np.arange(1, self.N+1) b = blaze.array(b) d = nd.array(a) cr = blaze._elwise_eval("a * b + d", vm=self.vm) nr = a * b + d assert_array_equal(cr[:], nr, "eval does not work correctly")
def test04(self): """Testing elwise_eval() with blaze, dynd and numpy arrays""" a, b = np.arange(self.N), np.arange(1, self.N+1) c = blaze.array(a, ddesc=self.ddesc1) d = nd.array(b) cr = blaze._elwise_eval("a * c + d", vm=self.vm, ddesc=self.ddesc3) nr = a * c + d assert_array_equal(cr[:], nr, "eval does not work correctly")
def test01(self): """Testing elwise_eval() with blaze arrays and constants""" a, b = np.arange(self.N), np.arange(1, self.N+1) c = blaze.array(a, ddesc=self.ddesc1) d = blaze.array(b, ddesc=self.ddesc2) cr = blaze._elwise_eval("c * d + 1", vm=self.vm, ddesc=self.ddesc3) nr = a * b + 1 assert_array_equal(cr[:], nr, "eval does not work correctly")
def test03(self): """Testing elwise_eval() with blaze and dynd arrays""" a = np.arange(self.N*self.M).reshape(self.N, self.M) b = np.arange(1, self.N*self.M+1).reshape(self.N, self.M) c = blaze.array(a, ddesc=self.ddesc1) d = nd.array(b) cr = blaze._elwise_eval("c * d + 1", vm=self.vm, ddesc=self.ddesc3) nr = a * b + 1 assert_array_equal(cr[:], nr, "eval does not work correctly")
def test00(self): """Testing elwise_eval() with only blaze arrays""" a = np.arange(self.N*self.M).reshape(self.N, self.M) b = np.arange(1, self.N*self.M+1).reshape(self.N, self.M) c = blaze.array(a, ddesc=self.ddesc1) d = blaze.array(b, ddesc=self.ddesc2) cr = blaze._elwise_eval("c * d", vm=self.vm, ddesc=self.ddesc3) nr = a * b assert_array_equal(cr[:], nr, "eval does not work correctly")
def test02(self): """Testing elwise_eval() with pure dynd arrays and scalars""" a = np.arange(self.N*self.M).reshape(self.N, self.M) b = np.arange(1, self.N*self.M+1).reshape(self.N, self.M) c = nd.array(a) d = nd.array(b) cr = blaze._elwise_eval("c * d + 2", vm=self.vm) nr = a * b + 2 assert_array_equal(cr[:], nr, "eval does not work correctly")
def test05(self): """Testing reductions on blaze arrays""" if self.vm == "python": # The reductions does not work well using Blaze expressions yet return a, b = np.arange(self.N), np.arange(1, self.N+1) b = blaze.array(b, ddesc=self.ddesc1) cr = blaze._elwise_eval("sum(b + 2)", vm=self.vm, ddesc=self.ddesc3) nr = np.sum(b + 2) self.assert_(cr == nr, "eval does not work correctly")
def test05(self): """Testing reductions on blaze arrays and axis=0""" if self.vm == "python": # The reductions does not work well using Blaze expressions yet return a = np.arange(self.N*self.M).reshape(self.N, self.M) b = np.arange(1, self.N*self.M+1).reshape(self.N, self.M) b = blaze.array(b) cr = blaze._elwise_eval("sum(b + 2, axis=0)", vm=self.vm) nr = np.sum(b + 2, axis=0) assert_array_equal(cr[:], nr, "eval does not work correctly")
def test02(self): """Testing with only numpy arrays""" a, b = np.arange(self.N), np.arange(1, self.N+1) cr = blaze._elwise_eval("a * b", vm=self.vm) nr = a * b assert_array_equal(cr[:], nr, "eval does not work correctly")
def test00(self): """Testing elwise_eval() with only scalars and constants""" a = 3 cr = blaze._elwise_eval("2 * a", vm=self.vm) self.assert_(cr == 6, "eval does not work correctly")