diff --git a/GPy/kern/src/stationary.py b/GPy/kern/src/stationary.py index 888320a0..527bb9bb 100644 --- a/GPy/kern/src/stationary.py +++ b/GPy/kern/src/stationary.py @@ -412,7 +412,6 @@ class Exponential(Stationary): # return (F, L, Qc, H, Pinf) - class OU(Stationary): """ OU kernel: @@ -426,6 +425,23 @@ class OU(Stationary): def __init__(self, input_dim, variance=1., lengthscale=None, ARD=False, active_dims=None, name='OU'): super(OU, self).__init__(input_dim, variance, lengthscale, ARD, active_dims, name) + def to_dict(self): + """ + Convert the object into a json serializable dictionary. + + Note: It uses the private method _save_to_input_dict of the parent. + + :return dict: json serializable dictionary containing the needed information to instantiate the object + """ + input_dict = super(OU, self)._save_to_input_dict() + input_dict["class"] = "GPy.kern.OU" + return input_dict + + @staticmethod + def _build_from_input_dict(kernel_class, input_dict): + useGPU = input_dict.pop('useGPU', None) + return OU(**input_dict) + def K_of_r(self, r): return self.variance * np.exp(-r) diff --git a/GPy/testing/serialization_tests.py b/GPy/testing/serialization_tests.py index d147d59c..93ec4b2d 100644 --- a/GPy/testing/serialization_tests.py +++ b/GPy/testing/serialization_tests.py @@ -26,14 +26,15 @@ class Test(unittest.TestCase): k7 = GPy.kern.Matern32(2, variance=1.0, lengthscale=[1.0,3.0], ARD=True, active_dims = [1,1]) k8 = GPy.kern.Matern52(2, variance=2.0, lengthscale=[2.0,1.0], ARD=True, active_dims = [1,0]) k9 = GPy.kern.ExpQuad(2, variance=3.0, lengthscale=[1.0,2.0], ARD=True, active_dims = [0,1]) - k10 = k1 + k1.copy() + k2 + k3 + k4 + k5 + k6 - k11 = k1 * k2 * k2.copy() * k3 * k4 * k5 - k12 = (k1 + k2) * (k3 + k4 + k5) - k13 = ((k1 + k2) * k3) + k4 + k5 * k7 - k14 = ((k1 + k2) * k3) + k4 * k5 + k8 - k15 = ((k1 * k2) * k3) + k4 * k5 + k8 + k9 + k10 = GPy.kern.OU(2, variance=2.0, lengthscale=[2.0, 1.0], ARD=True, active_dims=[1, 0]) + k11 = k1 + k1.copy() + k2 + k3 + k4 + k5 + k6 + k12 = k1 * k2 * k2.copy() * k3 * k4 * k5 + k13 = (k1 + k2) * (k3 + k4 + k5) + k14 = ((k1 + k2) * k3) + k4 + k5 * k7 + k15 = ((k1 + k2) * k3) + k4 * k5 + k8 * k10 + k16 = ((k1 * k2) * k3) + k4 * k5 + k8 + k9 - k_list = [k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15] + k_list = [k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11,k12,k13,k14,k15,k16] for kk in k_list: kk_dict = kk.to_dict() diff --git a/README.md b/README.md index 25a32658..1e609cb6 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,16 @@ We welcome any contributions to GPy, after all it is an open source project. We For an in depth description of pull requests, please visit https://help.github.com/articles/using-pull-requests/ . -### Steps to a successfull contribution: +### Steps to a successful contribution: 1. Fork GPy: https://help.github.com/articles/fork-a-repo/ 2. Make your changes to the source in your fork. 3. Make sure the [guidelines](#gl) are met. - 4. Set up tests to test your code. We are using unttests in the testing subfolder of GPy. There is a good chance that there is already a framework set up to test your new model in model_tests.py or kernel in kernel_tests.py. have a look at the source and you might be able to just add your model (or kernel or others) as an additional test in the appropriate file. There is more frameworks for testing the other bits and pieces, just head over to the testing folder and have a look. + 4. Set up tests to test your code. We are using unittests in the testing subfolder of GPy. There is a good chance + that there is already a framework set up to test your new model in model_tests.py or kernel in kernel_tests.py. have a look at the source and you might be able to just add your model (or kernel or others) as an additional test in the appropriate file. There is more frameworks for testing the other bits and pieces, just head over to the testing folder and have a look. 5. Create a pull request to the devel branch in GPy, see above. 6. The tests will be running on your pull request. In the comments section we will be able to discuss the changes and help you with any problems. Let us know if there are any in the comments, so we can help. - 7. The pull request gets accepted and your awsome new feature will be in the next GPy release :) + 7. The pull request gets accepted and your awesome new feature will be in the next GPy release :) For any further questions/suggestions head over to the issues section in GPy.