Esempio n. 1
0
def test_replace_applicator(tag):
    """ test_replace_applicator """
    fns = FnDict()
    partail = P.Partial()

    def app1(x, y):
        return scalar_add(x, y)

    def app2(x, y):
        return app1(x, y)

    def app3(x, y):
        return scalar_add(y, x)

    @fns
    def before1(x, y):
        return app1(x, y)

    @fns
    def before2(x, y):
        return app2(x, y)

    @fns
    def before3(x, y):
        return app3(x, y)

    @fns
    def after(x, y):
        return scalar_add(x, y)

    return fns[tag]
Esempio n. 2
0
def test_partial(tag):
    """ test_partial """
    fns = FnDict()
    partail = P.Partial()

    def f(x, y):
        return scalar_add(x, y)

    @fns
    def before(x, y):
        return partail(f, x)(y)

    @fns
    def after(x, y):
        return f(x, y)

    return fns[tag]
Esempio n. 3
0
def add3_scalar(x, y, z):
    return scala_add(scala_add(x, y), z)


@ms_function
def main_add3_easy(x, y):
    add2 = F.partial(add3_scalar, 1)
    return add2(x, y)


def test_hypermap_add3_easy():
    main_add3_easy(1, 2)


add3 = C.MultitypeFuncGraph('add')
partial = P.Partial()


@add3.register("Number", "Number", "Number")
def add3_scala(x, y, z):
    return scala_add(scala_add(x, y), z)


@add3.register("Number", "Tensor", "Tensor")
def add3_tensor(x, y, z):
    return tensor_add(y, z)


@ms_function
def main_add3_scala(x, y):
    add2 = partial(add3_scala, 1)