marionmari/pyGPs — pull request #17 by adrinjalali (2014-12-30 19:14:18+00:00)
Title: python 3 compatibility

Hi,

I managed to get it work with python 3, and all the tests except one pass now. I've added some code to print out some debug info, and somewhere an array is empty which is not supposed to be (`Core/cov.py` line 350). It would be nice if someone could help me fix this issue, and maybe have this code on a branch for python 3 if there's a plan for it.

$ python3 -u unit_test_model.py
Running unit tests(about 5 min)...
testing GP classification...
.testing GP sparse classification...
()
(120, 2)
()
(120, 2)
tuple index out of range
Traceback (most recent call last):
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 242, in findMin
thisopt = minimize.run(self._nlzAnddnlz, hypInArray, length=-40)
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Optimization/minimize.py", line 62, in run
result = f(X, *args)
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 66, in _nlzAnddnlz
nlZ, dnlZ, post = self.model.getPosterior()
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/gp.py", line 331, in getPosterior
post, nlZ, dnlZ = self.inffunc.evaluate(self.meanfunc, self.covfunc, self.likfunc, self.x, self.y, 3)
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/inf.py", line 819, in evaluate
diagK,Kuu,Ku = covfunc.getCovMatrix(x=x, mode='train') # evaluate the covariance matrix
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/cov.py", line 352, in getCovMatrix
assert(xu.shape[1] == x.shape[1])

...

======================================================================
ERROR: test_GPC_FITC (__main__.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "unit_test_model.py", line 109, in test_GPC_FITC
model.optimize(self.xc, self.yc)
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/gp.py", line 270, in optimize
optimalHyp, optimalNlZ = self.optimizer.findMin(self.x, self.y, numIters = numIterations)
File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 253, in findMin
raise Exception("Over half of the trails failed for minimize")
Exception: Over half of the trails failed for minimize

----------------------------------------------------------------------
Ran 4 tests in 10.816s

FAILED (errors=1)