# -*- coding: utf-8 -*- """ Created on Thu Apr 8 16:12:19 2021 @author: kkestel """ import numpy as np import elfi elfi_model = elfi.new_model('elfi_model') constant_node_list = [] dummy_array = np.arange(5) for i in dummy_array: name='Constant_'+str(i) dummy_constant = elfi.Constant(i,name=name,model=elfi_model) constant_node_list.append(elfi_model[name]) #%% First # Constant node list holds all the nodes that is expected to be parent of the operation node dummy_operation = elfi.Operation(np.add,constant_node_list,model=elfi_model,name='dummy_operation') # But this line above does not give any error and just create a separate dummy_operation error elfi.draw(elfi_model) #%% Second # This is how I want my DAG to look like. # But I may need to change the number of nodes which will be the parent of dummy operation # then desgining the script as below is not the most smart way dummy_operation2 = elfi.Operation(np.add, constant_node_list[0], constant_node_list[1], constant_node_list[2], constant_node_list[3], constant_node_list[4], model=elfi_model,name='dummy_operation2') elfi.draw(elfi_model) #%% Third # This one gives the error in the second iteration as dummy_operation 3 already exist for node in constant_node_list: dummy_operation3 = elfi.Operation(np.add, node, model=elfi_model,name='dummy_operation3') elfi.draw(elfi_model)