Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_chisq_no_priors():
data = np.array([1.1, 1.2, 0.9, 1.0])
model = np.array([1.0, 1.0, 1.0, 1.0])
uncert = np.array([0.1, 0.1, 0.1, 0.1])
chisq = ms.chisq(model, data, uncert)
assert chisq == 6.0
def test_chisq():
data = np.array([1.1, 1.2, 0.9, 1.0])
model = np.array([1.0, 1.0, 1.0, 1.0])
uncert = np.array([0.1, 0.1, 0.1, 0.1])
params = np.array([2.5, 5.5])
priors = np.array([2.0, 5.0])
plow = np.array([0.0, 1.0])
pup = np.array([0.0, 1.0])
chisq = ms.chisq(model, data, uncert, params, priors, plow, pup)
assert chisq == 6.25
"""
if self.wlike:
model = self.func(params[0:-3], *self.args)
else:
model = self.func(params, *self.args)
# Reject proposed iteration if any model value is infinite:
if np.any(model == np.inf):
chisq = np.inf
else:
# Calculate chisq:
if self.wlike:
chisq = ms.dwt_chisq(model, self.data, params,
self.prior, self.priorlow, self.priorup)
else:
chisq = ms.chisq(model, self.data, self.uncert,
params, self.prior, self.priorlow, self.priorup)
if ret == "both":
return [model, chisq]
elif ret == "chisq":
return chisq
else: # ret == "model"
return model