def test_sens(self):
"""Test the sign and magnitude of the sensitivity
"""
initial_data = {'simple': self.sim1({'simp': self.model})}
sens_matrix = self.bayes._get_sens(initial_data=initial_data)
indep = np.arange(10)
resp_mat = np.array([(1.02 * 2 * indep)**2 + 1 * indep -
(2 * indep)**2 - indep,
(2 * indep)**2 + 1.02 * indep -
(2 * indep)**2 - 1 * indep])
inp_mat = np.array([[0.02 * 2, 0], [0, 0.02]])
true_sens = np.linalg.lstsq(inp_mat, resp_mat)[0].T
npt.assert_array_almost_equal(sens_matrix['simple'], true_sens,
decimal=8,
err_msg='Sens matrix not as predicted')
resp_mat2 = resp_mat
resp_mat2[0, :] /= 0.04
resp_mat2[1, :] /= 0.02
npt.assert_array_almost_equal(sens_matrix['simple'], resp_mat2.T,
decimal=8,
err_msg='Sens matrix not as predicted')
评论列表
文章目录