示例#1
0
def math_op_deploy_test():
    out_node = PassThroughNode()
    add_node = AddNode()
    subtract_node = SubtractNode()
    multiply_node = MultiplyNode()
    divide_node = DivideNode()
    abs_node = AbsoluteValueNode()
    power_node = PowerNode()
    root_node = RootNode()
    log_node = LogNode()
    modulus_node = ModulusNode()

    BaseNode.connect(DataSourceNode(1), add_node, 'data', 'arg1')
    BaseNode.connect(DataSourceNode(4), add_node, 'data', 'arg2')
    BaseNode.connect(add_node, subtract_node, 'result', 'arg1')
    BaseNode.connect(DataSourceNode(1), subtract_node, 'data', 'arg2')
    BaseNode.connect(subtract_node, multiply_node, 'result', 'arg1')
    BaseNode.connect(DataSourceNode(4), multiply_node, 'data', 'arg2')
    BaseNode.connect(multiply_node, divide_node, 'result', 'arg1')
    BaseNode.connect(DataSourceNode(-2), divide_node, 'data', 'arg2')
    BaseNode.connect(divide_node, abs_node, 'result', 'in')
    BaseNode.connect(DataSourceNode(2), power_node, 'data', 'base')
    BaseNode.connect(abs_node, power_node, 'result', 'power')
    BaseNode.connect(DataSourceNode(2), root_node, 'data', 'root')
    BaseNode.connect(power_node, root_node, 'result', 'value')
    BaseNode.connect(DataSourceNode(2), log_node, 'data', 'base')
    BaseNode.connect(root_node, log_node, 'result', 'value')
    BaseNode.connect(log_node, modulus_node, 'result', 'arg1')
    BaseNode.connect(DataSourceNode(3), modulus_node, 'data', 'arg2')
    BaseNode.connect(modulus_node, out_node, 'result', 'in')

    print(out_node.resolve_output('out'))
    print(deploy(out_node, 'out', include_utils=False).__py__(DeployContext()))
示例#2
0
def deploy_test():
    loop_node = LoopNode()
    iter_node = IncrementNode()
    eq_node = EqualsNode()
    not_node = NotNode()
    var_node = VariableNode(0)
    split_node = DummyNode()
    add_node = AddNode()
    out_node = PassThroughNode()
    BaseNode.connect(loop_node, out_node, 'value', 'in')
    BaseNode.connect(split_node, loop_node, 'out', 'iter')
    BaseNode.connect(not_node, split_node, 'out', 'in')
    BaseNode.connect(eq_node, not_node, 'result', 'in')
    BaseNode.connect(iter_node, eq_node, 'increment', 'arg1')
    BaseNode.connect(DataSourceNode(50), eq_node, 'data', 'arg2')
    BaseNode.connect(var_node, loop_node, 'value', 'value')

    BaseNode.connect(var_node, split_node, 'update', 'extra')
    BaseNode.connect(add_node, var_node, 'result', 'value')
    BaseNode.connect(iter_node, add_node, 'value', 'arg1')
    BaseNode.connect(var_node, add_node, 'value', 'arg2')

    code = LanguageConcat(deploy(out_node, 'out'),
                          FunctionCall(VariableName('main')))
    print(code.__py__(DeployContext()))
示例#3
0
def reduce_node_test():
    reduce_node = ReduceNode()
    BaseNode.connect(DataSourceNode([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
                     reduce_node, 'data', 'array')
    add_node = AddNode()
    BaseNode.connect(reduce_node, add_node, 'accumulator', 'arg1')
    BaseNode.connect(reduce_node, add_node, 'current', 'arg2')
    BaseNode.connect(add_node, reduce_node, 'result', 'accumulator')
    print(deploy(reduce_node, 'reduced').__py__(DeployContext()))
示例#4
0
def math_round_deploy_test():
    out_node = PassThroughNode()
    round_node = RoundNode()
    BaseNode.connect(round_node, out_node, 'result', 'in')
    BaseNode.connect(DataSourceNode(5.49), round_node, 'data', 'value')

    print(out_node.resolve_output('out'))
    print(
        deploy(out_node, 'out', include_utils=False).__es6__(DeployContext()))
示例#5
0
def not_equals_test():
    out_node = PassThroughNode()
    from dataflow.bool._NotEqualsNode import NotEqualsNode
    not_equals_node = NotEqualsNode()
    BaseNode.connect(not_equals_node, out_node, 'result', 'in')
    BaseNode.connect(DataSourceNode(5.5), not_equals_node, 'data', 'arg1')
    BaseNode.connect(DataSourceNode(5.49), not_equals_node, 'data', 'arg2')

    print(out_node.resolve_output('out'))
    print(
        deploy(out_node, 'out', include_utils=False).__es6__(DeployContext()))
示例#6
0
def math_const_deploy_test():
    out_node = PassThroughNode()
    d1_node = DummyNode()
    print_node = PrintNode()
    BaseNode.connect(d1_node, out_node, 'out', 'in')
    BaseNode.connect(PiConstantNode(), d1_node, 'value', 'in')
    BaseNode.connect(print_node, d1_node, 'out', 'extra')
    BaseNode.connect(EulerConstantNode(), print_node, 'value', 'in')

    print(out_node.resolve_output('out'))
    print(
        deploy(out_node, 'out', include_utils=False).__es6__(DeployContext()))
示例#7
0
def filter_node_test():
    filter_node = FilterNode()
    BaseNode.connect(DataSourceNode([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]),
                     filter_node, 'data', 'array')
    mod_node = ModulusNode()
    eq_node = EqualsNode()
    BaseNode.connect(filter_node, mod_node, 'entry', 'arg1')
    BaseNode.connect(DataSourceNode(2), mod_node, 'data', 'arg2')
    BaseNode.connect(mod_node, eq_node, 'result', 'arg1')
    BaseNode.connect(DataSourceNode(0), eq_node, 'data', 'arg2')
    BaseNode.connect(eq_node, filter_node, 'result', 'keep')
    print(filter_node.resolve_output('filtered'))
    print(deploy(filter_node, 'filtered').__py__(DeployContext()))