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

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

        return array_map(add, xs, ys)
Example #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)
Example #3
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)
Example #4
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)
Example #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()
Example #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()
Example #7
0
    def f(x):
        def add1(x):
            return x + 1

        return array_map(add1, x)
Example #8
0
 def helper(fn):
     return array_map(fn, xs), array_map(fn, ys)
Example #9
0
def test_array_map_polymorphic(xs, ys):
    def square(x):
        return x * x

    return array_map(square, xs), array_map(square, ys)
Example #10
0
def test_array_map(xs):
    def square(x):
        return x * x

    return array_map(square, xs)
Example #11
0
def test_array_operations_distribute(x, y):
    xs = distribute(scalar_to_array(x, AA), (4, 3))
    ys = distribute(scalar_to_array(y, AA), (4, 3))
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
Example #12
0
    def before(xs):
        def f(x):
            return 3

        return array_map(f, xs)
Example #13
0
    def before(xs, ys):
        def f(x, y):
            return x * x + y * y

        return array_map(f, xs, ys)
Example #14
0
 def after(xs, ys):
     return array_map(scalar_add, ys, xs)
Example #15
0
    def before(xs, ys):
        def f(x, y):
            return scalar_add(y, x)

        return array_map(f, xs, ys)
Example #16
0
    def f(xs, ys):
        def add(x, y):
            return x + y

        return array_map(add, xs, ys)
Example #17
0
 def f(xs):
     return array_map(scalar_usub, xs)
Example #18
0
    def before(x):
        def p1(x):
            return x + 1

        return array_map(p1, x)
Example #19
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)
Example #20
0
 def up1(x2):
     return array_map(
         scalar_add,
         x2,
         distribute(scalar_to_array(1, typeof(x)), shape(x)),
     )
Example #21
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)
Example #22
0
 def f(xs, ys):
     return array_map(inl, xs, ys)