def test_get_sens(self):
"""
"""
sens = self.simSimp.get_sens(self.models, ['simp1', 'simp2'])
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_sens1 = np.linalg.lstsq(inp_mat, resp_mat)[0].T
indep = np.arange(10)
resp_mat = np.array([(1.02 * 3 * indep)**2 + 3 * indep -
(3 * indep)**2 - 3 * indep,
(3 * indep)**2 + 1.02 * 3 * indep -
(3 * indep)**2 - 3 * indep])
inp_mat = np.array([[0.02 * 3, 0], [0, 0.02 * 3]])
true_sens2 = np.linalg.lstsq(inp_mat, resp_mat)[0].T
# print(sens)
# print(true_sens1 - sens[:,:2])
# print(true_sens2 - sens[:,2:])
npt.assert_array_almost_equal(sens[:,:2], true_sens1)
npt.assert_array_almost_equal(sens[:,2:], true_sens2)
评论列表
文章目录