From 9e09535608ba567becb61f3995373c39e11b4753 Mon Sep 17 00:00:00 2001 From: imcovangent <I.vanGent@tudelft.nl> Date: Wed, 24 Jan 2018 09:15:24 +0100 Subject: [PATCH] Added impose_mdao_architecture() method. Former-commit-id: c53db447a57cd99c0a12cd12b2df5f813d4855e2 --- kadmos/graph/graph_data.py | 11 +++++++++++ kadmos/graph/graph_kadmos.py | 10 ++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/kadmos/graph/graph_data.py b/kadmos/graph/graph_data.py index 1fd9a02cb..3ba33abde 100644 --- a/kadmos/graph/graph_data.py +++ b/kadmos/graph/graph_data.py @@ -2674,6 +2674,17 @@ class FundamentalProblemGraph(DataGraph, KeChainMixin): return mdg + def impose_mdao_architecture(self): + """ + Method to directly get both the MDG and MPG of an FPG. + + :return: MdaoDataGraph and MdaoProcessGraph + :rtype: tuple + """ + mdg = self.get_mdg() + mpg = mdg.get_mpg() + return mdg, mpg + class MdaoDataGraph(DataGraph, MdaoMixin): diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py index fe73b299f..1683140eb 100644 --- a/kadmos/graph/graph_kadmos.py +++ b/kadmos/graph/graph_kadmos.py @@ -3140,8 +3140,10 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): function_order = source_funcs + new_targets # Assert that the function order given matches with the sources and targets - assert set(source_funcs).issubset(function_order), 'Some node sources are missing in the function order.' - assert set(target_funcs).issubset(function_order), 'Some node targets are missing in the function order.' + assert set(source_funcs).issubset(function_order), \ + 'Some node sources {} are missing in the function order {}.'.format(source_funcs, function_order) + assert set(target_funcs).issubset(function_order), \ + 'Some node targets {} are missing in the function order {}.'.format(target_funcs, function_order) # Make a first new node idx = 1 @@ -3217,8 +3219,8 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): """ # Input assertions - assert self.has_node(function), 'Node %s not present in the graph.' - assert self.node[function]['category'] == 'function', 'Node %s should be of category function.' + assert self.has_node(function), 'Node {} not present in the graph.'.format(function) + assert self.node[function]['category'] == 'function', 'Node {} should be of category function.'.format(function) assert isinstance(disconnect_collided_targets, bool) assert isinstance(disconnect_shared_sources, bool) assert isinstance(ignore_list, list) -- GitLab