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


Python Trajectory.f_add_parameter_group方法代码示例

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


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

示例1: test_iteration_failure

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_iteration_failure(self):
        traj = Trajectory()

        traj.f_add_parameter_group('test.test3')
        traj.f_add_parameter_group('test2')
        traj.test2.f_add_link(traj.test3)

        with self.assertRaises(pex.NotUniqueNodeError):
            traj.test3
开发者ID:MehmetTimur,项目名称:pypet,代码行数:11,代码来源:link_test.py

示例2: test_links_according_to_run

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_links_according_to_run(self):

        traj = Trajectory()

        traj.f_add_parameter('test.hi', 44)
        traj.f_explore({'hi': [1,2,3]})

        traj.f_add_parameter_group('test.test.test2')
        traj.f_add_parameter_group('test2')
        traj.test2.f_add_link('test', traj.test)

        traj.v_idx = 1
开发者ID:MehmetTimur,项目名称:pypet,代码行数:14,代码来源:link_test.py

示例3: test_link_of_link

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_link_of_link(self):

        traj = Trajectory()

        traj.f_add_parameter_group('test')
        traj.f_add_parameter_group('test2')

        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)


        self.assertTrue(traj.test.circle2 is traj.test)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:15,代码来源:link_test.py

示例4: test_not_getting_links

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_not_getting_links(self):
        traj = Trajectory()

        traj.f_add_parameter_group('test.test3')
        traj.f_add_parameter_group('test2')

        traj.test.f_add_link('circle1' , traj.test2)
        traj.test2.f_add_link('circle2' , traj.test)

        self.assertTrue(traj.test.circle1 is traj.test2)

        traj.v_with_links = False

        with self.assertRaises(AttributeError):
            traj.test.circle1

        found = False
        for item in traj.test.f_iter_nodes(recursive=True, with_links=True):
            if item is traj.test2:
                found=True

        self.assertTrue(found)

        for item in traj.test.f_iter_nodes(recursive=True, with_links=False):
            if item is traj.test2:
                self.assertTrue(False)

        traj.v_with_links=True
        self.assertTrue('circle1' in traj)
        self.assertFalse(traj.f_contains('circle1', with_links=False))

        self.assertTrue('circle1' in traj.test)
        self.assertFalse(traj.test.f_contains('circle1', with_links=False))

        self.assertTrue(traj.test2.test3 is traj.par.test.test3)
        traj.v_with_links = False
        with self.assertRaises(AttributeError):
            traj.test2.test3

        traj.v_with_links = True
        self.assertTrue(traj['test2.test3'] is traj.test3)

        with self.assertRaises(AttributeError):
            traj.f_get('test2.test3', with_links=False)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:46,代码来源:link_test.py

示例5: test_link_creation

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [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)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:45,代码来源:link_test.py

示例6: test_link_deletion

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_link_deletion(self):
        filename = make_temp_dir('linktest2.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.test.f_add_link('circle1' , traj.test2)
        traj.test2.f_add_link('circle2' , traj.test)

        traj.f_store()

        traj.f_delete_link('par.gg')

        traj2 = Trajectory(filename=filename)
        traj2.f_load(name=traj.v_name, load_data=2)

        with self.assertRaises(AttributeError):
            traj2.gg
开发者ID:MehmetTimur,项目名称:pypet,代码行数:23,代码来源:link_test.py

示例7: test_get_all_not_links

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_get_all_not_links(self):

        traj = Trajectory()

        traj.f_add_parameter('test.hi', 44)
        traj.f_explore({'hi': [1,2,3]})

        traj.f_add_parameter_group('test.test.test2')
        traj.f_add_parameter_group('test2')
        traj.test2.f_add_link('test', traj.test)

        nodes = traj.f_get_all('par.test')

        self.assertTrue(len(nodes) == 2)

        nodes = traj.f_get_all('par.test', shortcuts=False)

        self.assertTrue(len(nodes) == 1)

        traj.f_set_crun(0)

        traj.f_add_group('f.$.h')
        traj.f_add_group('f.$.g.h')
        traj.f_add_group('f.$.i')
        traj.crun.i.f_add_link('h', traj.crun.h)

        nodes = traj.f_get_all('$.h')

        self.assertTrue(len(nodes)==2)

        nodes = traj.f_get_all('h')

        self.assertTrue(len(nodes)==2)

        traj.v_idx = -1

        nodes = traj.f_get_all('h')

        self.assertTrue(len(nodes)==2)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:41,代码来源:link_test.py

示例8: test_link_removal

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
    def test_link_removal(self):
        traj = Trajectory()

        traj.f_add_parameter_group('test')
        traj.f_add_parameter_group('test2')

        traj.test.f_add_link('circle1' , traj.test2)
        traj.test2.f_add_link('circle2' , traj.test)

        self.assertTrue('circle1' in traj)
        traj.circle1.circle2.f_remove_link('circle1')
        self.assertTrue('circle1' not in traj.circle2)

        with self.assertRaises(AttributeError):
            traj.test.circle1

        with self.assertRaises(ValueError):
            traj.test.f_remove_link('circle1')

        traj.test2.f_remove_child('circle2')

        self.assertTrue('circle2' not in traj)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:24,代码来源:link_test.py

示例9: print

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]
# Or the get method
characters = traj.f_get('characters')

# Or square brackets
characters = traj['characters']

# Lets add another character
characters.f_add_parameter('luke_skywalker', 'Mark Hamill', comment='May the force be with you!')

#The full name of luke skywalker is now `parameters.starwars.characters.luke_skywalker`:
print('The full name of the new Skywalker Parameter is %s' %
      traj.f_get('luke_skywalker').v_full_name)

#Lets see what happens if we have not unique entries:
traj.f_add_parameter_group('spaceballs.characters')

# Now our shortcuts no longer work, since we have two character groups!
try:
    traj.characters
except NotUniqueNodeError as e:
    print('Damn it, there are two characters groups in the trajectory: %s' % e._msg)

# But if we are more specific we have again a unique finding
characters = traj.starwars.characters

# Now let's see what fast access is:
print('The name of the actor playing Luke is %s.' % traj.luke_skywalker)

# And now what happens if you forbid it
traj.v_fast_access=False
开发者ID:henribunting,项目名称:pypet,代码行数:32,代码来源:example_02_trajectory_access_and_storage.py

示例10: test_new_assignment_method

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [as 别名]

#.........这里部分代码省略.........

        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')
        with self.assertRaises(TypeError):
            traj.res.mu = DerivedParameterGroup('jj', comment='mi')
        with self.assertRaises(TypeError):
            traj.mu = DerivedParameterGroup('jj', comment='mi')

        with self.assertRaises(TypeError):
            traj.dpar.mu = ParameterGroup('jj', comment='mi')
        with self.assertRaises(TypeError):
            traj.res.mu = ParameterGroup('jj', comment='mi')
        with self.assertRaises(TypeError):
            traj.conf.mu = ParameterGroup('jj', comment='mi')
        with self.assertRaises(TypeError):
            traj.mu = ParameterGroup('jj', comment='mi')

        traj.par.mu = ParameterGroup('jj', comment='mi')
        traj.res.mus = ResultGroup('jj', comment='mi')
        traj.mu = NNGroupNode('jj')
        cg = ConfigGroup('a.g')
        traj.conf.a = cg

        self.assertTrue(traj.f_get('conf.a.a.g', shortcuts=False) is cg)

        dg = DerivedParameterGroup('ttt')
        traj.dpar.ttt = dg

        self.assertTrue(traj.f_get('dpar.ttt', shortcuts=False) is dg)

        traj.mylink = traj.par

        self.assertTrue(traj.mylink is traj.par)

        traj.vvv = NNGroupNode('', comment='kkk')

        self.assertTrue(traj.vvv.v_full_name == 'vvv')

        self.assertTrue(traj.par.mu.v_name == 'mu')

        traj.rrr = MyParamGroup('ff')

        traj.par.g = MyParamGroup('')

        pg = traj.f_add_parameter_group(comment='gg', full_name='me')
        self.assertTrue(traj.par.me is pg)

        traj.f_store()

        traj = load_trajectory(index=-1, filename=filename, dynamic_imports=MyParamGroup)

        self.assertTrue(isinstance(traj.rrr, NNGroupNode))
        self.assertTrue(isinstance(traj.rrr.ff, MyParamGroup))
        self.assertTrue(isinstance(traj.par.g, MyParamGroup))

        traj.par = Parameter('hiho', 42, comment='you')
        traj.par = Parameter('g1.g2.g3.g4.g5', 43)

        self.assertTrue(traj.hiho == 42)
        self.assertTrue(isinstance(traj.par.g1, ParameterGroup ))
        self.assertTrue(isinstance(traj.par.g3, ParameterGroup ))
        self.assertTrue(traj.g3.g5 == 43)
开发者ID:henribunting,项目名称:pypet,代码行数:104,代码来源:storage_test.py

示例11: test_storage_and_loading

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_add_parameter_group [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)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:64,代码来源:link_test.py


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