From 2877c62aa5971494a23c58352e1c80dfb882d757 Mon Sep 17 00:00:00 2001 From: jorgemfm27 Date: Mon, 17 Feb 2020 16:20:48 +0100 Subject: [PATCH 1/3] added cal func args --- autodepgraph/graph.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/autodepgraph/graph.py b/autodepgraph/graph.py index a903bba..b8b5e35 100644 --- a/autodepgraph/graph.py +++ b/autodepgraph/graph.py @@ -85,6 +85,9 @@ def add_node(self, node_for_adding, **attr): 'autodepgraph.node_functions.calibration_functions' + '.NotImplementedCalibration') + attr['calibrate_function_args'] = attr.get( + 'calibrate_function_args', None) + attr['check_function'] = attr.get( 'check_function', 'autodepgraph.node_functions.check_functions' + @@ -253,8 +256,10 @@ def calibrate_node(self, node, verbose=False): self.set_node_state(node, 'active') func = _get_function(self.nodes[node]['calibrate_function']) + func_args = self.nodes[node]['calibrate_function_args'] + try: - result = func() + result = func(**func_args) except Exception as e: self.set_node_state(node, 'bad') logging.warning(e) @@ -303,7 +308,7 @@ def update_monitor_mpl(self): def _generate_node_positions(self, node_positions={}): nodes=self.nodes() - + def position_generator(N=10, centre=[0,5]): """ Generate circle of positions around centre """ idx=0 @@ -312,11 +317,11 @@ def position_generator(N=10, centre=[0,5]): pos = 2.1*np.array([np.cos(phi), np.sin(phi)]) + centre yield pos idx=idx+1 - - positions=position_generator(len(nodes)) + + positions=position_generator(len(nodes)) pos=dict([ (node, node_positions.get(node, next(positions)) ) for node in nodes] ) - return pos - + return pos + def draw_mpl(self, ax=None): if ax is None: f, ax = plt.subplots() From 8b10c52a83413545c81caa388b531d7617388321 Mon Sep 17 00:00:00 2001 From: jorgemfm27 Date: Mon, 17 Feb 2020 17:11:24 +0100 Subject: [PATCH 2/3] implemented suggested changes --- autodepgraph/graph.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autodepgraph/graph.py b/autodepgraph/graph.py index b8b5e35..3b903f3 100644 --- a/autodepgraph/graph.py +++ b/autodepgraph/graph.py @@ -85,8 +85,8 @@ def add_node(self, node_for_adding, **attr): 'autodepgraph.node_functions.calibration_functions' + '.NotImplementedCalibration') - attr['calibrate_function_args'] = attr.get( - 'calibrate_function_args', None) + attr['calibrate_function_kwargs'] = attr.get( + 'calibrate_function_kwargs', {}) attr['check_function'] = attr.get( 'check_function', @@ -256,10 +256,10 @@ def calibrate_node(self, node, verbose=False): self.set_node_state(node, 'active') func = _get_function(self.nodes[node]['calibrate_function']) - func_args = self.nodes[node]['calibrate_function_args'] + func_kwargs = self.nodes[node]['calibrate_function_kwargs'] try: - result = func(**func_args) + result = func(**func_kwargs) except Exception as e: self.set_node_state(node, 'bad') logging.warning(e) From e57b8b9202ce175551a4cea678d56693c431fa42 Mon Sep 17 00:00:00 2001 From: Adriaan Date: Wed, 12 Aug 2020 16:33:27 +0200 Subject: [PATCH 3/3] Update autodepgraph/graph.py Co-authored-by: Pieter Eendebak --- autodepgraph/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autodepgraph/graph.py b/autodepgraph/graph.py index f9e5fbd..5f92ef9 100644 --- a/autodepgraph/graph.py +++ b/autodepgraph/graph.py @@ -96,7 +96,7 @@ def add_node(self, node_for_adding, **attr): 'autodepgraph.node_functions.calibration_functions' + '.NotImplementedCalibration') - attr['calibrate_function_kwargs'] = attr.get( + attr.setdefault('calibrate_function_kwargs', {}) 'calibrate_function_kwargs', {}) attr['check_function'] = attr.get(