Skip to content

Commit

Permalink
Merge pull request #75 from jorgemfm27/develop
Browse files Browse the repository at this point in the history
added cal func args
  • Loading branch information
AdriaanRol authored Aug 12, 2020
2 parents 51f9ff0 + e57b8b9 commit 36d3ac3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions autodepgraph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def add_node(self, node_for_adding, **attr):
'autodepgraph.node_functions.calibration_functions' +
'.NotImplementedCalibration')

attr.setdefault('calibrate_function_kwargs', {})
'calibrate_function_kwargs', {})

attr['check_function'] = attr.get(
'check_function',
'autodepgraph.node_functions.check_functions' +
Expand Down Expand Up @@ -280,8 +283,10 @@ def calibrate_node(self, node : str, verbose : bool =False):
self.set_node_state(node, 'active')

func = _get_function(self.nodes[node]['calibrate_function'])
func_kwargs = self.nodes[node]['calibrate_function_kwargs']

try:
result = func()
result = func(**func_kwargs)
except Exception as e:
self.set_node_state(node, 'bad')
logging.warning(e)
Expand Down Expand Up @@ -333,6 +338,7 @@ def _generate_node_positions(self, node_positions : Optional[dict] = None):

if node_positions is None:
node_positions = {}

def position_generator(N=10, centre=[0,5]):
""" Generate circle of positions around centre """
idx=0
Expand All @@ -341,8 +347,8 @@ 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

Expand Down

0 comments on commit 36d3ac3

Please sign in to comment.