Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working auto differentiation, enables the hmc on test cases. #53

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion cpnest/cpnest.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self,
maxmcmc,
verbose = verbose,
output = output,
poolsize = poolsize,
poolsize = 1,
johnveitch marked this conversation as resolved.
Show resolved Hide resolved
seed = self.seed+i,
proposal = proposals['hmc'](model=self.user),
resume_file = resume_file,
Expand Down
18 changes: 8 additions & 10 deletions cpnest/parameter.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ cimport numpy as np
import numpy as np

cpdef LivePoint rebuild_livepoint(names):
cdef LivePoint lp=LivePoint(names)
return lp
cdef LivePoint lp=LivePoint(names)
return lp

cdef class LivePoint:
"""
Expand All @@ -28,9 +28,9 @@ cdef class LivePoint:
self.names = names
self.dimension = len(names)
if d is not None:
self.values = array.array('d',d)
self.values = array.array('d',d)
else:
self.values = array.array('d',[0]*self.dimension)
self.values = array.array('d',[0]*self.dimension)

def keys(self):
return self.names
Expand All @@ -42,12 +42,12 @@ cdef class LivePoint:
return self.__class__.__name__+'({0:s}, d={1:s}, logL={2:f}, logP={3:f})'.format(str(self.names),str(self.values),self.logL,self.logP)

def __getstate__(self):
return (self.logL,self.logP,self.values)
return (self.logL,self.logP,self.values)

def __setstate__(self,state):
self.logL=state[0]
self.logP=state[1]
self.values=array.array('d',state[2])
self.logL=state[0]
self.logP=state[1]
self.values=array.array('d',state[2])

def __str__(LivePoint self):
return str({n:self[n] for n in self.names})
Expand Down Expand Up @@ -150,5 +150,3 @@ cdef class LivePoint:
x['logL'] = self.logL
x['logPrior'] = self.logP
return x


Loading