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_residuals_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])
res = ms.residuals(model, data, uncert)
np.testing.assert_allclose(res, np.array([-1.0, -2.0, 1.0, 0.0]))
def test_residuals():
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])
res = ms.residuals(model, data, uncert, params, priors, plow, pup)
np.testing.assert_allclose(res, np.array([-1.0, -2.0, 1.0, 0.0, 0.5]))
Returns
-------
Array of weighted data-model and prior-params residuals.
"""
# Update params with fitparams:
params[ifree] = fitparams
# Update shared parameters:
for s in ishare:
params[s] = params[-int(pstep[s])-1]
# Compute model:
model = func(params, *indparams)
# Calculate residuals:
residuals = ms.residuals(model, data, uncert, params, prior,
priorlow, priorup)
return residuals