def all_or_nothing(matrix, graph, results):
aux_res = MultiThreadedAoN()
aux_res.prepare(graph, results)
# catch errors
if results.__graph_id__ is None:
raise ValueError('The results object was not prepared. Use results.prepare(graph)')
elif results.__graph_id__ != graph.__id__:
raise ValueError('The results object was prepared for a different graph')
else:
pool = ThreadPool(results.cores)
all_threads = {'count': 0}
report = []
for O in range(matrix.shape[0]):
a = matrix[O, :]
if np.sum(a) > 0:
pool.apply_async(func_assig_thread, args=(O, a, graph, results, aux_res, all_threads, report))
pool.close()
pool.join()
results.link_loads = np.sum(aux_res.temp_link_loads, axis=1)
return report
评论列表
文章目录