Exemple #1
0
 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))
Exemple #2
0
 def test_graph(self):
     a = array(np.arange(10), dshape=dshape('10, int32'))
     b = array(np.arange(10), dshape=dshape('10, float32'))
     expr = add(a, mul(a, b))
     graph, ctx = expr.expr
     self.assertEqual(len(ctx.params), 2)
     self.assertFalse(ctx.constraints)
     self.assertEqual(graph.dshape, dshape('10, float64'))
Exemple #3
0
 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))
Exemple #4
0
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
Exemple #5
0
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