test_Simulation.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:F_UNCLE 作者: fraserphysics 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号