From c3066366161ad3863eacd78abf0987eddec1bdc8 Mon Sep 17 00:00:00 2001 From: Neil Lawrence Date: Wed, 28 Aug 2013 13:56:00 +0200 Subject: [PATCH] Added unit tests for mapping functions. --- GPy/testing/mapping_tests.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 GPy/testing/mapping_tests.py diff --git a/GPy/testing/mapping_tests.py b/GPy/testing/mapping_tests.py new file mode 100644 index 00000000..578c3dac --- /dev/null +++ b/GPy/testing/mapping_tests.py @@ -0,0 +1,28 @@ +# Copyright (c) 2012, 2013 GPy authors (see AUTHORS.txt). +# Licensed under the BSD 3-clause license (see LICENSE.txt) + +import unittest +import numpy as np +import GPy + + + +class MappingTests(unittest.TestCase): + + def test_kernelmapping(self): + verbose = False + mapping = GPy.mappings.Kernel(np.random.rand(10, 3), 2) + self.assertTrue(GPy.core.mapping.Mapping_check_df_dtheta(mapping=mapping).checkgrad(verbose=verbose)) + self.assertTrue(GPy.core.mapping.Mapping_check_df_dX(mapping=mapping).checkgrad(verbose=verbose)) + + def test_linearmapping(self): + verbose = False + mapping = GPy.mappings.Linear(3, 2) + self.assertTrue(GPy.core.Mapping_check_df_dtheta(mapping=mapping).checkgrad(verbose=verbose)) + self.assertTrue(GPy.core.Mapping_check_df_dX(mapping=mapping).checkgrad(verbose=verbose)) + + + +if __name__ == "__main__": + print "Running unit tests, please be (very) patient..." + unittest.main()