Esempio n. 1
0
def test_op_dtype4():
    a = NDArray([1], dshape='1, int')
    b = NDArray([2], dshape='1, int')

    x = (a + b)

    x.simple_type() == dshape('int')
Esempio n. 2
0
def test_complex_pipeline1():
    a = NDArray([1, 2, 3])
    b = NDArray([1, 2, 3])
    c = NDArray([1, 2, 3])
    d = NDArray([1, 2, 3])

    line = Pipeline()
    _, plan = line.run_pipeline(((a * b) + (c * d))**2)

    # Pow(
    #   Arithmetic(
    #     Add
    #   , Arithmetic(
    #       Mul
    #     , Array(){dshape("3,int64"), 40127160}
    #     , Array(){dshape("3,int64"), 40015272}
    #     ){dshape("int64"), 40076400}
    #   , Arithmetic(
    #       Mul
    #     , Array{dshape("3,int64"), 40069816}
    #     , Array{dshape("3,int64"), 40080448}
    #     ){dshape("int64"), 40076016}
    #   ){dshape("int64"), 40077552}
    # , 2{dshape("int"), 40090448}
    # ){dshape("int64"), 40077744}

    if DEBUG:
        pprint(plan, width=1)
Esempio n. 3
0
def test_op_dtype6():
    a = NDArray([1], dshape='x, int')
    b = NDArray([2], dshape='x, float')

    x = (a + b)

    with assert_raises(NotSimple):
        x.simple_type()
Esempio n. 4
0
def test_complex_pipeline2():
    a = NDArray([1, 2, 3])
    b = NDArray([1, 2, 3])
    c = NDArray([1, 2, 3])
    d = NDArray([1, 2, 3])

    f = ((a * b) + (c * d))
    g = f**(a + b)

    line = Pipeline()
    _, plan = line.run_pipeline(f + g)

    #   Arithmetic(
    #     Add()
    #   , Arithmetic(
    #       Add()
    #     , Arithmetic(
    #         Mul()
    #       , Array(){dshape("3, int64"), 61582152}
    #       , Array(){dshape("3, int64"), 61469976}
    #       ){dshape("int64"), 61526768}
    #     , Arithmetic(
    #         Mul()
    #       , Array(){dshape("3, int64"), 61524520}
    #       , Array(){dshape("3, int64"), 61531056}
    #       ){dshape("int64"), 61526864}
    #     ){dshape("int64"), 61527152}
    #   , Pow(
    #       Arithmetic(
    #         Add()
    #       , Arithmetic(
    #           Mul()
    #         , Array(){dshape("3, int64"), 61582152}
    #         , Array(){dshape("3, int64"), 61469976}
    #         ){dshape("int64"), 61526768}
    #       , Arithmetic(
    #           Mul()
    #         , Array(){dshape("3, int64"), 61524520}
    #         , Array(){dshape("3, int64"), 61531056}
    #         ){dshape("int64"), 61526864}
    #       ){dshape("int64"), 61527152}
    #     , Arithmetic(
    #         Add()
    #       , Array(){dshape("3, int64"), 61582152}
    #       , Array(){dshape("3, int64"), 61469976}
    #       ){dshape("int64"), 61528304}
    #     ){dshape("int64"), 61528496}
    #   ){dshape("int64"), 61528592}

    if DEBUG:
        pprint(plan, width=1)
Esempio n. 5
0
def test_slice():
    a = NDArray([])

    x = a[0:1]

    if DEBUG:
        dump(x, filename='slice')
Esempio n. 6
0
def test_indexing():
    a = NDArray([])

    x = a[0]

    if DEBUG:
        dump(x, filename='indexer')
Esempio n. 7
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
Esempio n. 8
0
def test_dynamic_arguments():
    a = NDArray([])
    b = NDArray([a])

    children = b.children
    assert len(children) == 1
Esempio n. 9
0
def test_scalar_arguments():
    a = NDArray([1, 2, 3])
    children = a.children
Esempio n. 10
0
def test_op_dtype7():
    a = NDArray([1], dshape='1, 2, int')
    b = NDArray([2], dshape='2, 3, float')

    x = (a + b)
    x.simple_type() == dshape('float')
Esempio n. 11
0
def test_broadcast():
    x = NDArray([1, 2, 3])
    y = NDArray([1, 2, 3])
    res = broadcast(x, y)
Esempio n. 12
0
from unittest import skip

DEBUG = False

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

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

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

d = NDArray([1, 2, 3])

#------------------------------------------------------------------------
# Tests
#------------------------------------------------------------------------


@skip
def test_simple_sort():
    lst = toposort(lambda x: True, x)
    assert len(lst) == 6


@skip
def test_simple_sort_ops():
    lst = topops(y)