当前位置: 首页>>代码示例>>Python>>正文


Python Trajectory.f_remove_item方法代码示例

本文整理汇总了Python中pypet.Trajectory.f_remove_item方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_remove_item方法的具体用法?Python Trajectory.f_remove_item怎么用?Python Trajectory.f_remove_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypet.Trajectory的用法示例。


在下文中一共展示了Trajectory.f_remove_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_whole_subtrees

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_item [as 别名]
    def test_delete_whole_subtrees(self):
        filename = make_temp_dir('testdeltree.hdf5')
        traj = Trajectory(name='TestDelete',
                          filename=filename, large_overview_tables=True)

        res = traj.f_add_result('mytest.yourtest.test', a='b', c='d')
        dpar = traj.f_add_derived_parameter('mmm.gr.dpdp', 666)


        res = traj.f_add_result('hhh.ll', a='b', c='d')
        res = traj.f_add_derived_parameter('hhh.gg', 555)

        traj.f_store()

        with ptcompat.open_file(filename) as fh:
            daroot = ptcompat.get_child(fh.root, traj.v_name)
            dpar_table = daroot.overview.derived_parameters_overview
            self.assertTrue(len(dpar_table) == 2)
            res_table = daroot.overview.results_overview
            self.assertTrue((len(res_table)) == 2)

        with self.assertRaises(TypeError):
            traj.f_remove_item(traj.yourtest)

        with self.assertRaises(TypeError):
            traj.f_delete_item(traj.yourtest)

        traj.f_remove_item(traj.yourtest, recursive=True)

        self.assertTrue('mytest' in traj)
        self.assertTrue('yourtest' not in traj)

        traj.f_load(load_data=2)

        self.assertTrue('yourtest.test' in traj)

        traj.f_delete_item(traj.yourtest, recursive=True, remove_from_trajectory=True)
        traj.f_delete_item(traj.mmm, recursive=True, remove_from_trajectory=True)

        traj.f_load(load_data=2)

        self.assertTrue('yourtest.test' not in traj)
        self.assertTrue('yourtest' not in traj)

        with ptcompat.open_file(filename) as fh:
            daroot = ptcompat.get_child(fh.root, traj.v_name)
            dpar_table = daroot.overview.derived_parameters_overview
            self.assertTrue(len(dpar_table) == 2)
            res_table = daroot.overview.results_overview
            self.assertTrue((len(res_table)) == 2)

        traj.f_add_parameter('ggg', 43)
        traj.f_add_parameter('hhh.mmm', 45)
        traj.f_add_parameter('jjj', 55)
        traj.f_add_parameter('hhh.nnn', 55555)

        traj.f_explore({'ggg':[1,2,3]})

        traj.f_store()

        with ptcompat.open_file(filename) as fh:
            daroot = ptcompat.get_child(fh.root, traj.v_name)
            par_table = daroot.overview.parameters_overview
            self.assertTrue(len(par_table) == 4)

        traj.f_delete_item('par.hhh', recursive=True, remove_from_trajectory=True)

        traj.f_add_parameter('saddsdfdsfd', 111)
        traj.f_store()

        with ptcompat.open_file(filename) as fh:
            daroot = ptcompat.get_child(fh.root, traj.v_name)
            par_table = daroot.overview.parameters_overview
            self.assertTrue(len(par_table) == 5)

        # with self.assertRaises(TypeError):
        #     # We cannot delete something containing an explored parameter
        #     traj.f_delete_item('par', recursive=True)

        with self.assertRaises(TypeError):
            traj.f_delete_item('ggg')
开发者ID:henribunting,项目名称:pypet,代码行数:83,代码来源:storage_test.py


注:本文中的pypet.Trajectory.f_remove_item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。