コード例 #1
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_binary_ops():
    a = IntNode(1)
    b = IntNode(2)

    x = a + b

    if DEBUG:
        dump(x, filename='binary')
コード例 #2
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_scalars():
    a = IntNode(1)
    b = IntNode(1)
    c = IntNode(2)

    x = abs((a + b + c + 3) * 4)

    if DEBUG:
        dump(x, filename='scalars')
コード例 #3
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_unary_ops():
    a = IntNode(1)

    x = abs(a)

    if DEBUG:
        dump(x, filename='unary')
コード例 #4
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_binary_mixed():
    a = IntNode(1)

    x = a + 2

    if DEBUG:
        dump(x, filename='binarymixed')
コード例 #5
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_preserve_types():
    a = IntNode(1)
    b = FloatNode(1.0)

    x = a + b
    assert isinstance(x, App)
    assert x.dom == [float64, float64]
    assert x.cod == float64
コード例 #6
0
def test_promote():
    from blaze.expr.graph import IntNode, FloatNode

    # ----------------------------------
    x, y = IntNode(1), FloatNode(1.)
    res = promote(x, y)

    ## TODO: check if this is platform specific
    assert res == blaze.float64
    ## ----------------------------------
    x, y = IntNode(1), IntNode(1)
    res = promote(x, y)

    assert res == blaze.int32
    # ----------------------------------
    x = NDArray([1, 2, 3], dshape('3, int32'))
    y = NDArray([1, 2, 3], dshape('3, int32'))
    res = promote(x, y)
    assert res == blaze.int32
コード例 #7
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_op_dtype2():
    a = IntNode(1)
    b = FloatNode(1.)

    x = (a + b)
    x.simple_type() == dshape('float')
コード例 #8
0
ファイル: test_construction.py プロジェクト: garfee/blaze
def test_op_dtype():
    a = IntNode(1)
    b = IntNode(1)

    x = (a + b)
    x.simple_type() == dshape('int')
コード例 #9
0
ファイル: test_visitor.py プロジェクト: renjiec/blaze-core
 def FloatNode(self, node):
     return IntNode(3)
コード例 #10
0
ファイル: test_visitor.py プロジェクト: renjiec/blaze-core
from blaze.expr.graph import IntNode, FloatNode
from blaze import visitor

#------------------------------------------------------------------------
# Sample Graph
#------------------------------------------------------------------------

a = IntNode(1)
b = IntNode(2)
c = FloatNode(3.0)

x = a + (b + c)
y = a + b + c

#------------------------------------------------------------------------
# Visitors
#------------------------------------------------------------------------


class Visitor(visitor.BasicGraphVisitor):
    def App(self, tree):
        return self.visit(tree.children)

    def IntNode(self, tree):
        return int

    def FloatNode(self, tree):
        return float

    def Add(self, tree):
        return self.visit(tree.children)