本文整理汇总了Python中pypet.Trajectory.f_add_link方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_add_link方法的具体用法?Python Trajectory.f_add_link怎么用?Python Trajectory.f_add_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_add_link方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_links
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_link [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
示例2: test_new_assignment_method
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_link [as 别名]
def test_new_assignment_method(self):
filename = make_temp_dir('newassignment.hdf5')
traj = Trajectory(filename=filename)
traj.v_lazy_adding = True
comment = 'A number'
traj.par.x = 44, comment
self.assertTrue(traj.f_get('x').v_comment == comment)
traj.par.iamgroup = a_new_group
self.assertTrue(isinstance(traj.iamgroup, ParameterGroup))
traj.v_lazy_adding = False
traj.x = 45
self.assertTrue(traj.par.f_get('x').f_get() == 45)
self.assertTrue(isinstance(traj.f_get('x'), Parameter))
traj.f = Parameter('lll', 444, 'lll')
self.assertTrue(traj.f_get('f').v_name == 'f')
traj.v_lazy_adding = True
traj.res.k = 22, 'Hi'
self.assertTrue(isinstance(traj.f_get('k'), Result))
self.assertTrue(traj.f_get('k')[1] == 'Hi')
with self.assertRaises(AttributeError):
traj.res.k = 33, 'adsd'
conf = traj.conf
with self.assertRaises(AttributeError):
conf = traj.conf.jjjj
traj.f_set_properties(fast_access=True)
traj.crun = 43, 'JJJ'
self.assertTrue(traj.run_A[0] == 43)
with self.assertRaises(AttributeError):
traj.f_set_properties(j=7)
with self.assertRaises(AttributeError):
traj.f_set_properties(depth=7)
traj.hui = (('444', 'kkkk',), 'l')
self.assertTrue(traj.f_get('hui')[1] == 'l')
with self.assertRaises(AttributeError):
traj.hui = ('445', 'kkkk',)
traj.f_get('hui').f_set(('445', 'kkkk',))
self.assertTrue(traj.f_get('hui')[1] == 'l')
self.assertTrue(traj.hui[0] == ('445', 'kkkk',))
traj.f_add_link('klkikju', traj.par) # for shizzle
traj.meee = Result('h', 43, hui = 3213, comment='du')
self.assertTrue(traj.meee.h.h == 43)
with self.assertRaises(TypeError):
traj.par.mu = NNGroupNode('jj', comment='mi')
with self.assertRaises(TypeError):
traj.res.mu = NNGroupNode('jj', comment='mi')
with self.assertRaises(TypeError):
traj.conf.mu = NNGroupNode('jj', comment='mi')
with self.assertRaises(TypeError):
traj.dpar.mu = NNGroupNode('jj', comment='mi')
with self.assertRaises(TypeError):
traj.par.mu = ResultGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.dpar.mu = ResultGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.conf.mu = ResultGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.mu = ResultGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.par.mu = ConfigGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.dpar.mu = ConfigGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.res.mu = ConfigGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.mu = ConfigGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.par.mu = DerivedParameterGroup('jj', comment='mi')
with self.assertRaises(TypeError):
traj.conf.mu = DerivedParameterGroup('jj', comment='mi')
#.........这里部分代码省略.........
示例3: test_link_creation
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_link [as 别名]
def test_link_creation(self):
traj = Trajectory()
traj.f_add_parameter_group('test.test3')
traj.f_add_parameter_group('test2')
with self.assertRaises(AttributeError):
traj.par.f_add_link('test', traj.test2)
with self.assertRaises(ValueError):
traj.f_add_link('parameters', traj.test)
with self.assertRaises(ValueError):
traj.f_add_link('kkkk', PickleResult('fff', 555))
traj.test.f_add_link('circle1' , traj.test2)
traj.test2.f_add_link('circle2' , traj.test)
self.assertTrue(traj.test.circle1.circle2.circle1.circle2 is traj.test)
traj.f_add_link('hh', traj.test)
traj.par.f_add_link('overview', traj.test)
with self.assertRaises(ValueError):
traj.f_add_link('overview', traj.test)
with self.assertRaises(ValueError):
traj.f_add_link('v_crun')
with self.assertRaises(ValueError):
traj.par.f_add_link('gg', traj)
with self.assertRaises(AttributeError):
traj.f_add_parameter('test.circle1.testy', 33)
traj.par.f_add_link('gg', traj.circle1)
self.assertTrue(traj.gg is traj.test2)
self.assertTrue(traj.test2.test3 is traj.par.test.test3)
traj.f_add_link(traj.test3)
self.assertTrue('test3' in traj._links)
示例4: test_storage_and_loading
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_link [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)