mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-08 19:42:39 +02:00
pydot graphing half done
This commit is contained in:
parent
82e3252012
commit
16e2fbd6cb
2 changed files with 29 additions and 0 deletions
|
|
@ -60,6 +60,15 @@ class Param(Constrainable, ObservableArray, Gradcheckable):
|
|||
def __init__(self, name, input_array, default_constraint=None, *a, **kw):
|
||||
super(Param, self).__init__(name=name, default_constraint=default_constraint, *a, **kw)
|
||||
|
||||
def build_pydot(self,G):
|
||||
import pydot
|
||||
node = pydot.Node(id(self), shape='record', label=self.name)
|
||||
G.add_node(node)
|
||||
for o in self._observer_callables_.keys():
|
||||
print o, self.hirarchy_name()
|
||||
|
||||
return node
|
||||
|
||||
def __array_finalize__(self, obj):
|
||||
# see InfoArray.__array_finalize__ for comments
|
||||
if obj is None: return
|
||||
|
|
|
|||
|
|
@ -64,6 +64,26 @@ class Parameterized(Parameterizable, Pickleable, Gradcheckable):
|
|||
self._connect_parameters()
|
||||
del self._in_init_
|
||||
|
||||
def build_pydot(self, G=None):
|
||||
import pydot
|
||||
iamroot = False
|
||||
if G is None:
|
||||
G = pydot.Dot(graph_type='digraph')
|
||||
iamroot=True
|
||||
node = pydot.Node(id(self), shape='record', label=self.name)
|
||||
G.add_node(node)
|
||||
for child in self._parameters_:
|
||||
child_node = child.build_pydot(G)
|
||||
G.add_edge(pydot.Edge(node, child_node))
|
||||
|
||||
for o in self._observer_callables_.keys():
|
||||
print id(o), self.hirarchy_name()
|
||||
|
||||
if iamroot:
|
||||
return G
|
||||
return node
|
||||
|
||||
|
||||
def add_parameter(self, param, index=None):
|
||||
"""
|
||||
:param parameters: the parameters to add
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue