answer_testing_support.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def __call__(self):
        # Read in the ds
        ds = load(self.data_file)
        ds.setup_deprecated_fields()
        exact = self.get_analytical_solution()

        ad = ds.all_data()
        position = ad['x']
        for k in self.fields:
            field = ad[k].d
            for xmin, xmax in zip(self.left_edges, self.right_edges):
                mask = (position >= xmin)*(position <= xmax)
                exact_field = np.interp(position[mask], exact['pos'], exact[k])
                myname = "ShockTubeTest_%s" % k
                # yield test vs analytical solution 
                yield AssertWrapper(myname, assert_allclose, field[mask], 
                                    exact_field, self.rtol, self.atol)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号