本文整理汇总了Python中pypet.Trajectory.f_remove_child方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_remove_child方法的具体用法?Python Trajectory.f_remove_child怎么用?Python Trajectory.f_remove_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_remove_child方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_default
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_get_default(self):
traj = Trajectory(name='Testgetdefault', filename=make_temp_dir('autoload.hdf5'))
traj.v_auto_load = True
traj.f_add_result('I.am.$.a.mean.resu', 42, comment='Test')
val = traj.f_get_default('jjjjjjjjjj', 555)
self.assertTrue(val==555)
traj.f_store()
traj.f_remove_child('results', recursive=True)
val = traj.f_get_default('res.I.am.crun.a.mean.answ', 444, auto_load=True)
self.assertTrue(val==444)
val = traj.f_get_default('res.I.am.crun.a.mean.resu', auto_load=True, fast_access=True)
self.assertTrue(val==42)
with self.assertRaises(Exception):
traj.kdsfdsf
示例2: test_partial_loading
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_partial_loading(self):
traj = Trajectory(name='TestPartial', filename=make_temp_dir('testpartially.hdf5'))
res = traj.f_add_result('mytest.test', a='b', c='d')
traj.f_store()
traj.f_remove_child('results', recursive=True)
traj.f_load_skeleton()
traj.f_load_item(traj.test, load_only=['a', 'x'])
self.assertTrue('a' in traj.test)
self.assertTrue('c' not in traj.test)
traj.f_remove_child('results', recursive=True)
traj.f_load_skeleton()
load_except= ['c', 'd']
traj.f_load_item(traj.test, load_except=load_except)
self.assertTrue(len(load_except)==2)
self.assertTrue('a' in traj.test)
self.assertTrue('c' not in traj.test)
with self.assertRaises(ValueError):
traj.f_load_item(traj.test, load_except=['x'], load_only=['y'])
示例3: test_auto_load
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [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
示例4: test_delete_links
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_delete_links(self):
traj = Trajectory(name='TestDelete',
filename=make_temp_dir('testpartiallydel.hdf5'),
add_time=True)
res = traj.f_add_result('mytest.test', a='b', c='d')
traj.f_add_link('x.y', res)
traj.f_add_link('x.g.h', res)
traj.f_store()
traj.f_remove_child('x', recursive=True)
traj.f_load()
self.assertEqual(traj.x.y.a, traj.test.a)
self.assertEqual(traj.x.g.h.a, traj.test.a)
traj.f_delete_link('x.y', remove_from_trajectory=True)
traj.f_delete_link((traj.x.g, 'h'), remove_from_trajectory=True)
traj.f_load()
with self.assertRaises(AttributeError):
traj.x.g.h
示例5: test_store_overly_long_comment
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_store_overly_long_comment(self):
filename = make_temp_dir('remove_errored.hdf5')
traj = Trajectory(name='traj', add_time=True, filename=filename)
res=traj.f_add_result('iii', 42, 43, comment=7777 * '6')
traj.f_store()
traj.f_remove_child('results', recursive=True)
traj.f_load_child('results', recursive=True)
self.assertTrue(traj.iii.v_comment == 7777 * '6')
示例6: test_wildcard_search
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_wildcard_search(self):
traj = Trajectory(name='Testwildcard', filename=make_temp_dir('wilcard.hdf5'),
add_time=True)
traj.f_add_parameter('expl', 2)
traj.f_explore({'expl':[1,2,3,4]})
traj.f_add_result('wc2test.$.hhh', 333)
traj.f_add_leaf('results.wctest.run_00000000.jjj', 42)
traj.f_add_result('results.wctest.run_00000001.jjj', 43)
traj.f_add_result('results.wctest.%s.jjj' % traj.f_wildcard('$', -1), 43)
traj.v_crun = 1
self.assertTrue(traj.results.wctest['$'].jjj==43)
self.assertTrue(traj.results.wc2test.crun.hhh==333)
traj.f_store()
get_root_logger().info('Removing child1')
traj.f_remove_child('results', recursive=True)
get_root_logger().info('Doing auto-load')
traj.v_auto_load = True
self.assertTrue(traj.results.wctest['$'].jjj==43)
self.assertTrue(traj.results.wc2test.crun.hhh==333)
get_root_logger().info('Removing child2')
traj.f_remove_child('results', recursive=True)
get_root_logger().info('auto-loading')
traj.v_auto_load = True
self.assertTrue(traj.results.wctest[-1].jjj==43)
self.assertTrue(traj.results.wc2test[-1].hhh==333)
get_root_logger().info('Removing child3')
traj.f_remove_child('results', recursive=True)
get_root_logger().info('auto-loading')
traj.v_auto_load = True
self.assertTrue(traj.results.wctest[1].jjj==43)
self.assertTrue(traj.results.wc2test[-1].hhh==333)
get_root_logger().info('Done with wildcard test')
示例7: test_storage_and_loading
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_remove_child [as 别名]
def test_storage_and_loading(self):
filename = make_temp_dir('linktest.hdf5')
traj = Trajectory(filename=filename)
traj.f_add_parameter_group('test')
traj.f_add_parameter_group('test2')
res= traj.f_add_result('kk', 42)
traj.par.f_add_link('gg', res)
traj.f_add_link('hh', res)
traj.f_add_link('jj', traj.par)
traj.f_add_link('ii', res)
traj.test.f_add_link('circle1' , traj.test2)
traj.test2.f_add_link('circle2' , traj.test)
traj.test.f_add_link('circle2' , traj.test.circle1.circle2)
traj.f_add_parameter_group('test.ab.bc.cd')
traj.cd.f_add_link(traj.test)
traj.test.f_add_link(traj.cd)
traj.f_store()
traj2 = Trajectory(filename=filename)
traj2.f_load(name=traj.v_name, load_data=2)
self.assertTrue(traj.kk == traj2.gg, '%s != %s' % (traj.kk, traj2.gg))
self.assertTrue(traj.cd.test is traj.test)
self.assertTrue(len(traj._linked_by), len(traj2._linked_by))
self.compare_trajectories(traj, traj2)
self.assertTrue('jj' in traj2._nn_interface._links_count)
traj2.f_remove_child('jj')
self.assertTrue('jj' not in traj2._nn_interface._links_count)
traj2.f_remove_child('hh')
traj2.f_remove_child('ii')
traj2.f_remove_child('parameters', recursive=True)
traj2.v_auto_load = True
group = traj2.par.test2.circle2
self.assertTrue(group is traj2.test)
retest = traj2.test.circle1
self.assertTrue(retest is traj2.test2)
self.assertTrue(traj2.test.circle2 is traj2.test)
self.assertTrue(traj2.hh == traj2.res.kk)
traj2.v_auto_load = False
traj2.f_load_child('jj')
self.assertTrue(traj2.jj is traj2.par)
traj2.f_load(load_data=2)
self.assertTrue(traj2.ii == traj2.res.kk)