예제 #1
0
    def f(xs, ys):
        z = 1 + 1

        def add(x, y):
            return x + y + z

        return array_map(add, xs, ys)
예제 #2
0
    def after(xs, ys, z):
        def g(x):
            return x * x * x

        def f(x, y):
            return (x * x * x) + (y * y * y)
        return array_map(f, xs, ys), g(z + 1), g(z + 2)
예제 #3
0
    def before(xs, ys, z):
        def g(x):
            return x * x * x

        def f(x, y):
            return g(x) + g(y)
        return array_map(f, xs, ys), g(z + 1), g(z + 2)
예제 #4
0
    def before(xs, ys, z):
        def f(x, y):
            def g(x):
                return x * y

            return g(x)

        return array_map(f, xs, ys)
예제 #5
0
def test_prim_array_map():
    v = np.zeros((2, 3))

    def f(a):
        return a + 1

    v2 = array_map(f, v)

    assert (v == 0).all()
    assert (v2 == 1).all()
예제 #6
0
def test_prim_array_map2():
    v1 = np.ones((2, 3))
    v2 = np.ones((2, 3))

    def f(a, b):
        return a + b

    vres = array_map(f, v1, v2)

    assert (v1 == 1).all()
    assert (v2 == 1).all()
    assert (vres == 2).all()
예제 #7
0
    def before(x):
        def p1(x):
            return x + 1

        return array_map(p1, x)
예제 #8
0
 def f(xs):
     return array_map(scalar_usub, xs)
예제 #9
0
    def before(xs):
        def f(x):
            return 3

        return array_map(f, xs)
예제 #10
0
    def before(xs, ys):
        def f(x, y):
            return x * x + y * y

        return array_map(f, xs, ys)
예제 #11
0
def test_array_operations_reshape(xs, ys):
    xs = reshape(xs, (6, ))
    ys = reshape(ys, (6, ))
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
예제 #12
0
def test_array_map3(ary1, ary2, ary3):
    def f(v1, v2, v3):
        return v1 + v2 + v3

    return array_map(f, ary1, ary2, ary3)
예제 #13
0
def test_array_map2(ary1, ary2):
    def f(v1, v2):
        return v1 + v2

    return array_map(f, ary1, ary2)
예제 #14
0
def test_array_operations(xs, ys):
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
예제 #15
0
 def up1(x):
     return array_map(scalar_add, x,
                      distribute(scalar_to_array(1), (2, 3)))
예제 #16
0
파일: test_vm.py 프로젝트: stjordanis/myia
    def f(xs, ys):
        def add(x, y):
            return x + y

        return array_map(add, xs, ys)
예제 #17
0
파일: test_vm.py 프로젝트: stjordanis/myia
    def f(x):
        def add1(x):
            return x + 1

        return array_map(add1, x)
예제 #18
0
def test_array_map_polymorphic(xs, ys):
    def square(x):
        return x * x

    return array_map(square, xs), array_map(square, ys)
예제 #19
0
def test_array_map(xs):
    def square(x):
        return x * x

    return array_map(square, xs)
예제 #20
0
 def helper(fn):
     return array_map(fn, xs), array_map(fn, ys)
예제 #21
0
 def up1(x2):
     return array_map(
         scalar_add, x2,
         distribute(scalar_to_array(1, typeof(x)), shape(x)))
예제 #22
0
def test_array_map(ary):
    def f(v):
        return v + 1

    return array_map(f, ary)
예제 #23
0
    def before(xs, ys):
        def f(x, y):
            return scalar_add(y, x)

        return array_map(f, xs, ys)
예제 #24
0
def test_array_map0():
    def f():
        return 1

    return array_map(f)
예제 #25
0
 def after(xs, ys):
     return array_map(scalar_add, ys, xs)
예제 #26
0
def _mystery2(x, y):
    return array_map(scalar_add, x, y)
예제 #27
0
def test_array_operations_distribute(x, y):
    xs = distribute(scalar_to_array(x), (4, 3))
    ys = distribute(scalar_to_array(y), (4, 3))
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)