mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-07 19:12:40 +02:00
bug fix for extending prod kernel
This commit is contained in:
parent
10bfb47aa6
commit
afbb8ab253
2 changed files with 11 additions and 1 deletions
|
|
@ -162,6 +162,10 @@ class Kern(Parameterized):
|
|||
def __mul__(self, other):
|
||||
""" Here we overload the '*' operator. See self.prod for more information"""
|
||||
return self.prod(other)
|
||||
|
||||
def __imul__(self, other):
|
||||
""" Here we overload the '*' operator. See self.prod for more information"""
|
||||
return self.prod(other)
|
||||
|
||||
def __pow__(self, other):
|
||||
"""
|
||||
|
|
@ -183,7 +187,7 @@ class Kern(Parameterized):
|
|||
:type tensor: bool
|
||||
|
||||
"""
|
||||
assert isinstance(other, Kern), "only kernels can be added to kernels..."
|
||||
assert isinstance(other, Kern), "only kernels can be multiplied to kernels..."
|
||||
from prod import Prod
|
||||
#kernels = []
|
||||
#if isinstance(self, Prod): kernels.extend(self.parameters)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ class Prod(CombinationKernel):
|
|||
|
||||
"""
|
||||
def __init__(self, kernels, name='mul'):
|
||||
for i, kern in enumerate(kernels[:]):
|
||||
if isinstance(kern, Prod):
|
||||
del kernels[i]
|
||||
for part in kern.parts[::-1]:
|
||||
kern.unlink_parameter(part)
|
||||
kernels.insert(i, part)
|
||||
super(Prod, self).__init__(kernels, name)
|
||||
|
||||
@Cache_this(limit=2, force_kwargs=['which_parts'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue