mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 12:02:38 +02:00
highest parent fix
This commit is contained in:
parent
75241ecf89
commit
ef3bfa4676
2 changed files with 13 additions and 6 deletions
|
|
@ -153,6 +153,8 @@ class Param(ObservableArray, Constrainable):
|
||||||
@property
|
@property
|
||||||
def _parameters_(self):
|
def _parameters_(self):
|
||||||
return []
|
return []
|
||||||
|
def _connect_highest_parent(self, highest_parent):
|
||||||
|
self._highest_parent_ = highest_parent
|
||||||
def _collect_gradient(self, target):
|
def _collect_gradient(self, target):
|
||||||
target[:] = self.gradient.flat
|
target[:] = self.gradient.flat
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
|
||||||
|
|
@ -217,13 +217,9 @@ class Parameterized(Constrainable, Pickleable, Observable):
|
||||||
self._param_slices_ = []
|
self._param_slices_ = []
|
||||||
for p in self._parameters_:
|
for p in self._parameters_:
|
||||||
p._direct_parent_ = self
|
p._direct_parent_ = self
|
||||||
p._highest_parent_ = self
|
|
||||||
p._parent_index_ = i
|
p._parent_index_ = i
|
||||||
|
p._connect_highest_parent(self)
|
||||||
i += 1
|
i += 1
|
||||||
for pi in p.flattened_parameters:
|
|
||||||
pi._highest_parent_ = self
|
|
||||||
for pi in p._parameters_:
|
|
||||||
pi._highest_parent_ = self
|
|
||||||
not_unique = []
|
not_unique = []
|
||||||
sizes.append(p.size+sizes[-1])
|
sizes.append(p.size+sizes[-1])
|
||||||
self._param_slices_.append(slice(sizes[-2], sizes[-1]))
|
self._param_slices_.append(slice(sizes[-2], sizes[-1]))
|
||||||
|
|
@ -238,6 +234,15 @@ class Parameterized(Constrainable, Pickleable, Observable):
|
||||||
self.__dict__[pname] = p
|
self.__dict__[pname] = p
|
||||||
self._added_names_.add(pname)
|
self._added_names_.add(pname)
|
||||||
|
|
||||||
|
def _connect_highest_parent(self, highest_parent):
|
||||||
|
self._highest_parent_ = highest_parent
|
||||||
|
if not hasattr(self, "_parameters_") or len(self._parameters_) < 1:
|
||||||
|
# no parameters for this class
|
||||||
|
return
|
||||||
|
for p in self._parameters_:
|
||||||
|
p._highest_parent_ = highest_parent
|
||||||
|
p._connect_highest_parent(highest_parent)
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Pickling operations
|
# Pickling operations
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue