def _create_node(self, fct, inputs, outputs, args_names, kwargs_names): """ create a save the node to the graph """ inputs = get_if_exists(inputs, self._inputs) outputs = get_if_exists(outputs, self._outputs) node = Node(fct, inputs, outputs, args_names, kwargs_names) # assume that we cannot have two nodes with the same output names for n in self._nodes.values(): for out_name in n.output_names: if out_name in node.output_names: msg = '{} output already exist'.format(out_name) raise PyungoError(msg) self._nodes[node.id] = node
def test_get_if_exists_do_not_exists(): res = get_if_exists([1, 2, 3], []) assert res == [1, 2, 3]
def test_get_if_exists_ok(): inputs = [Input("a"), Input("b"), Input("c")] existing = {i.name: i for i in inputs} res = get_if_exists(["a", "b", "c", {"d": 3}], existing) for i, j in zip(inputs, res): # skip the dict on purpose assert i == j
def test_get_if_exists_ok(): inputs = [Input('a'), Input('b'), Input('c')] existing = {i.name: i for i in inputs} res = get_if_exists(['a', 'b', 'c', {'d': 3}], existing) for i, j in zip(inputs, res): # skip the dict on purpose assert i == j