mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-12 13:32:39 +02:00
tests ignored my nosetests (__test__ = False)
This commit is contained in:
parent
5abe3dee4c
commit
0332fa14f8
1 changed files with 48 additions and 43 deletions
|
|
@ -8,6 +8,8 @@ import GPy
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pylab
|
import pylab
|
||||||
|
|
||||||
|
__test__ = False
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
D = 9
|
D = 9
|
||||||
M = 5
|
M = 5
|
||||||
|
|
@ -30,49 +32,52 @@ class Test(unittest.TestCase):
|
||||||
self.q_x_mean.shape = (1, self.D)
|
self.q_x_mean.shape = (1, self.D)
|
||||||
self.q_x_variance.shape = (1, self.D)
|
self.q_x_variance.shape = (1, self.D)
|
||||||
|
|
||||||
# def test_psi0(self):
|
def test_psi0(self):
|
||||||
# for kern in self.kerns:
|
for kern in self.kerns:
|
||||||
# psi0 = kern.psi0(self.Z, self.q_x_mean, self.q_x_variance)
|
psi0 = kern.psi0(self.Z, self.q_x_mean, self.q_x_variance)
|
||||||
# Kdiag = kern.Kdiag(self.q_x_samples)
|
Kdiag = kern.Kdiag(self.q_x_samples)
|
||||||
# self.assertAlmostEqual(psi0, np.mean(Kdiag), 1)
|
self.assertAlmostEqual(psi0, np.mean(Kdiag), 1)
|
||||||
# # print kern.parts[0].name, np.allclose(psi0, np.mean(Kdiag))
|
# print kern.parts[0].name, np.allclose(psi0, np.mean(Kdiag))
|
||||||
#
|
|
||||||
# def test_psi1(self):
|
def test_psi1(self):
|
||||||
# for kern in self.kerns:
|
for kern in self.kerns:
|
||||||
# Nsamples = 100
|
Nsamples = 100
|
||||||
# psi1 = kern.psi1(self.Z, self.q_x_mean, self.q_x_variance)
|
psi1 = kern.psi1(self.Z, self.q_x_mean, self.q_x_variance)
|
||||||
# K_ = np.zeros((self.N, self.M))
|
K_ = np.zeros((self.N, self.M))
|
||||||
# diffs = []
|
diffs = []
|
||||||
# for i, q_x_sample_stripe in enumerate(np.array_split(self.q_x_samples, self.Nsamples / Nsamples)):
|
for i, q_x_sample_stripe in enumerate(np.array_split(self.q_x_samples, self.Nsamples / Nsamples)):
|
||||||
# K = kern.K(q_x_sample_stripe, self.Z)
|
K = kern.K(q_x_sample_stripe, self.Z)
|
||||||
# K_ += K
|
K_ += K
|
||||||
# diffs.append(((psi1 - (K_ / (i + 1))) ** 2).mean())
|
diffs.append(((psi1 - (K_ / (i + 1))) ** 2).mean())
|
||||||
# K_ /= self.Nsamples / Nsamples
|
K_ /= self.Nsamples / Nsamples
|
||||||
# # pylab.figure("+".join([p.name for p in kern.parts]) + "psi1")
|
# pylab.figure("+".join([p.name for p in kern.parts]) + "psi1")
|
||||||
# # pylab.plot(diffs)
|
# pylab.plot(diffs)
|
||||||
# self.assertTrue(np.allclose(psi1.flatten() , K.mean(0), rtol=1e-1))
|
self.assertTrue(np.allclose(psi1.flatten() , K.mean(0), rtol=1e-1))
|
||||||
#
|
|
||||||
# def test_psi2(self):
|
def test_psi2(self):
|
||||||
# for kern in self.kerns:
|
for kern in self.kerns:
|
||||||
# Nsamples = 100
|
Nsamples = 100
|
||||||
# psi2 = kern.psi2(self.Z, self.q_x_mean, self.q_x_variance)
|
psi2 = kern.psi2(self.Z, self.q_x_mean, self.q_x_variance)
|
||||||
# K_ = np.zeros((self.M, self.M))
|
K_ = np.zeros((self.M, self.M))
|
||||||
# diffs = []
|
diffs = []
|
||||||
# for i, q_x_sample_stripe in enumerate(np.array_split(self.q_x_samples, self.Nsamples / Nsamples)):
|
for i, q_x_sample_stripe in enumerate(np.array_split(self.q_x_samples, self.Nsamples / Nsamples)):
|
||||||
# K = kern.K(q_x_sample_stripe, self.Z)
|
K = kern.K(q_x_sample_stripe, self.Z)
|
||||||
# K = (K[:, :, None] * K[:, None, :]).mean(0)
|
K = (K[:, :, None] * K[:, None, :]).mean(0)
|
||||||
# K_ += K
|
K_ += K
|
||||||
# diffs.append(((psi2 - (K_ / (i + 1))) ** 2).mean())
|
diffs.append(((psi2 - (K_ / (i + 1))) ** 2).mean())
|
||||||
# K_ /= self.Nsamples / Nsamples
|
K_ /= self.Nsamples / Nsamples
|
||||||
# try:
|
try:
|
||||||
# # pylab.figure("+".join([p.name for p in kern.parts]) + "psi2")
|
# pylab.figure("+".join([p.name for p in kern.parts]) + "psi2")
|
||||||
# # pylab.plot(diffs)
|
# pylab.plot(diffs)
|
||||||
# self.assertTrue(np.allclose(psi2.squeeze(), K_,
|
self.assertTrue(np.allclose(psi2.squeeze(), K_,
|
||||||
# rtol=1e-1, atol=.1),
|
rtol=1e-1, atol=.1),
|
||||||
# msg="{}: not matching".format("+".join([p.name for p in kern.parts])))
|
msg="{}: not matching".format("+".join([p.name for p in kern.parts])))
|
||||||
# except:
|
except:
|
||||||
# print "{}: not matching".format(kern.parts[0].name)
|
print "{}: not matching".format(kern.parts[0].name)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys;sys.argv = ['', 'Test.test_psi2']
|
import sys;sys.argv = ['',
|
||||||
|
'Test.test_psi0',
|
||||||
|
'Test.test_psi1',
|
||||||
|
'Test.test_psi2']
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue