Пример #1
0
 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'))
Пример #2
0
 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'))
Пример #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))
Пример #4
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))
Пример #5
0
 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))
Пример #6
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 = multiply(add(a, b), c)
    graph, expr_ctx = result.expr

    f = from_expr(graph, expr_ctx, {})

    return f, graph
Пример #7
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 = multiply(add(a, b), c)
    graph, expr_ctx = result.expr

    f = from_expr(graph, expr_ctx, {})

    return f, graph
Пример #8
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 * complex[float64]'))

    result = multiply(add(a, b), c)
    graph, expr_ctx = result.expr

    f = from_expr(graph, expr_ctx, {})

    return f, graph
Пример #9
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
Пример #10
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
Пример #11
0
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