本文整理汇总了Python中pypet.Trajectory.f_add_derived_parameter方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_add_derived_parameter方法的具体用法?Python Trajectory.f_add_derived_parameter怎么用?Python Trajectory.f_add_derived_parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_add_derived_parameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auto_load
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_derived_parameter [as 别名]
def test_auto_load(self):
traj = Trajectory(name='Testautoload', filename=make_temp_dir('autoload.hdf5'))
traj.v_auto_load = True
traj.f_add_result('I.am.$.a.mean.resu', 42, comment='Test')
traj.f_add_derived_parameter('ffa', 42)
traj.f_store()
ffa=traj.f_get('ffa')
ffa.f_unlock()
ffa.f_empty()
self.assertTrue(ffa.f_is_empty())
traj.f_remove_child('results', recursive=True)
# check auto load
val = traj.res.I.am.crun.a.mean.resu
self.assertTrue(val==42)
val = traj.ffa
self.assertTrue(val==42)
with self.assertRaises(pex.DataNotInStorageError):
traj.kdsfdsf
示例2: test_find_in_all_runs_with_links
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_derived_parameter [as 别名]
def test_find_in_all_runs_with_links(self):
traj = Trajectory()
traj.f_add_parameter('FloatParam')
traj.par.FloatParam=4.0
self.explore_dict = {'FloatParam':[1.0,1.1,1.2,1.3]}
traj.f_explore(self.explore_dict)
self.assertTrue(len(traj) == 4)
traj.f_add_result('results.runs.run_00000000.sub.resulttest', 42)
traj.f_add_result('results.runs.run_00000001.sub.resulttest', 43)
traj.f_add_result('results.runs.run_00000002.sub.resulttest', 44)
traj.f_add_result('results.runs.run_00000002.sub.resulttest2', 42)
traj.f_add_result('results.runs.run_00000003.sub.resulttest2', 43)
traj.f_add_derived_parameter('derived_parameters.runs.run_00000002.testing', 44)
res_dict = traj.f_get_from_runs('resulttest', fast_access=True)
self.assertTrue(len(res_dict)==3)
self.assertTrue(res_dict['run_00000001']==43)
self.assertTrue('run_00000003' not in res_dict)
res_dict = traj.f_get_from_runs(name='sub.resulttest2', use_indices=True)
self.assertTrue(len(res_dict)==2)
self.assertTrue(res_dict[3] is traj.f_get('run_00000003.resulttest2'))
self.assertTrue(1 not in res_dict)
traj.res.runs.r_0.f_add_link('resulttest2', traj.r_1.f_get('resulttest'))
res_dict = traj.f_get_from_runs(name='resulttest2', use_indices=True)
self.assertTrue(len(res_dict)==3)
self.assertTrue(res_dict[0] is traj.f_get('run_00000001.resulttest'))
self.assertTrue(1 not in res_dict)
res_dict = traj.f_get_from_runs(name='resulttest2', use_indices=True, with_links=False)
self.assertTrue(len(res_dict)==2)
self.assertTrue(0 not in res_dict)
self.assertTrue(1 not in res_dict)
示例3: test_migrations
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_derived_parameter [as 别名]
def test_migrations(self):
traj = Trajectory(name='Testmigrate', filename=make_temp_dir('migrate.hdf5'))
traj.f_add_result('I.am.a.mean.resu', 42, comment='Test')
traj.f_add_derived_parameter('ffa', 42)
traj.f_store()
new_file = make_temp_dir('migrate2.hdf5')
traj.f_migrate(filename=new_file)
traj.f_store()
new_traj = Trajectory()
new_traj.f_migrate(new_name=traj.v_name, filename=new_file, in_store=True)
new_traj.v_auto_load=True
self.assertTrue(new_traj.results.I.am.a.mean.resu == 42)
示例4: test_delete_whole_subtrees
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_derived_parameter [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')