def test_graph(self): a = array(nd.range(10, dtype=ndt.int32)) b = array(nd.range(10, dtype=ndt.float32)) expr = add(a, multiply(a, b)) graph, ctx = expr.expr self.assertEqual(len(ctx.params), 2) self.assertFalse(ctx.constraints) self.assertEqual(graph.dshape, dshape('10, float64'))
def test_graph(self): a = array(nd.range(10, dtype=ndt.int32)) b = array(nd.range(10, dtype=ndt.float32)) expr = add(a, multiply(a, b)) graph, ctx = expr.expr self.assertEqual(len(ctx.params), 2) self.assertFalse(ctx.constraints) self.assertEqual(graph.dshape, dshape('10 * float64'))
def test_interp(self): a = array(range(10), dshape=dshape('10, int32')) b = array(range(10), dshape=dshape('10, float32')) expr = add(a, mul(a, b)) result = blaze.eval(expr, strategy='py') expected = blaze.array([ 0, 2, 6, 12, 20, 30, 42, 56, 72, 90]) self.assertEqual(type(result), blaze.Array) self.assertTrue(np.all(result == expected))
def test_jit_scalar(self): a = blaze.array(range(10), dshape=dshape('10, int32')) b = 10 expr = add(a, mul(a, b)) result = blaze.eval(expr) np_a = np.arange(10) expected = np_a + np_a * b self.assertTrue(np.all(result == expected))
def test_exec_scalar(self): a = blaze.array(range(10), dshape=dshape('10, int32')) b = 10 expr = add(a, multiply(a, b)) result = blaze.eval(expr) np_a = np.arange(10) expected = np_a + np_a * b self.assertTrue(np.all(result == expected))
def make_graph(): a = blaze.array(range(10), dshape("10, int32")) b = blaze.array(range(10), dshape("10, float64")) c = blaze.array([i + 0j for i in range(10)], dshape("10, complex128")) result = multiply(add(a, b), c) graph, expr_ctx = result.expr f = from_expr(graph, expr_ctx, {}) return f, graph
def make_graph(): a = blaze.array(range(10), dshape('10, int32')) b = blaze.array(range(10), dshape('10, float64')) c = blaze.array([i + 0j for i in range(10)], dshape('10, complex128')) result = multiply(add(a, b), c) graph, expr_ctx = result.expr f = from_expr(graph, expr_ctx, {}) return f, graph
def make_graph(): a = blaze.array(range(10), dshape('10 * int32')) b = blaze.array(range(10), dshape('10 * float64')) c = blaze.array([i+0j for i in range(10)], dshape('10 * complex[float64]')) result = multiply(add(a, b), c) graph, expr_ctx = result.expr f = from_expr(graph, expr_ctx, {}) return f, graph
def make_graph(): a = blaze.array(range(10), dshape('10, int32')) b = blaze.array(range(10), dshape('10, float64')) c = blaze.array([i+0j for i in range(10)], dshape('10, complex128')) result = mul(add(a, b), c) graph, expr_ctx = result.expr ctx = ExecutionContext() f, values = from_expr(graph, expr_ctx, ctx) return f, values, graph
def make_expr(ds1, ds2): a = array(range(10), dshape=ds1) b = array(range(10), dshape=ds2) expr = add(a, mul(a, b)) return expr
def make_expr(ds1, ds2): a = array(range(10), dshape=ds1) b = array(range(10), dshape=ds2) expr = add(a, multiply(a, b)) return expr