• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python trajectory.Trajectory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

    def setUp(self):

        logging.basicConfig(level = logging.INFO)
        traj = Trajectory('Test')

        traj.v_storage_service = LazyStorageService()

        large_amount = 111

        for irun in range(large_amount):
            name = 'There.Are.Many.Parameters.Like.Me' + str(irun)

            traj.f_add_parameter(name, irun)


        traj.f_add_parameter('TestExplorer', 1)

        traj.v_fast_access=False
        traj.f_explore({traj.TestExplorer.v_full_name:[1,2,3,4,5]})
        traj.v_fast_access=True

        self.traj = traj
        self.n = 1
        self.single_run = self.traj._make_single_run(self.n)
        self.assertTrue(len(self.single_run)==1)
开发者ID:lsolanka,项目名称:pypet,代码行数:25,代码来源:trajectory_test.py


示例2: load_trajectory

 def load_trajectory(self,trajectory_index=None,trajectory_name=None,as_new=False):
     ### Load The Trajectory and check if the values are still the same
     newtraj = Trajectory()
     newtraj.v_storage_service=HDF5StorageService(filename=self.filename)
     newtraj.f_load(name=trajectory_name, load_derived_parameters=2,load_results=2,
                    index=trajectory_index, as_new=as_new)
     return newtraj
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:7,代码来源:hdf5_storage_test.py


示例3: test_a_large_run

    def test_a_large_run(self):
        get_root_logger().info('Testing large run')
        self.traj.f_add_parameter('TEST', 'test_run')
        ###Explore
        self.explore_large(self.traj)
        self.make_run_large_data()

        self.assertTrue(self.traj.f_is_completed())

        # Check if printing and repr work
        get_root_logger().info(str(self.env))
        get_root_logger().info(repr(self.env))

        newtraj = Trajectory()
        newtraj.f_load(name=self.traj.v_name, as_new=False, load_data=2, filename=self.filename)

        self.traj.f_load_skeleton()
        self.traj.f_load_items(self.traj.f_to_dict().keys(), only_empties=True)

        self.compare_trajectories(self.traj,newtraj)

        size=os.path.getsize(self.filename)
        size_in_mb = size/1000000.
        get_root_logger().info('Size is %sMB' % str(size_in_mb))
        self.assertTrue(size_in_mb < 30.0, 'Size is %sMB > 30MB' % str(size_in_mb))
开发者ID:MehmetTimur,项目名称:pypet,代码行数:25,代码来源:environment_test.py


示例4: test_partially_delete_stuff

    def test_partially_delete_stuff(self):
        traj = Trajectory(name='TestDelete',
                          filename=make_temp_file('testpartiallydel.hdf5'))

        res = traj.f_add_result('mytest.test', a='b', c='d')

        traj.f_store()

        self.assertTrue('a' in res)
        traj.f_delete_item(res, delete_only=['a'], remove_from_item=True)

        self.assertTrue('c' in res)
        self.assertTrue('a' not in res)

        res['a'] = 'offf'

        self.assertTrue('a' in res)

        traj.f_load(load_results=3)

        self.assertTrue('a' not in res)
        self.assertTrue('c' in res)

        traj.f_delete_item(res, remove_from_trajectory=True, remove_empty_groups=True)

        self.assertTrue('results' not in traj)
        self.assertTrue(res not in traj)
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:27,代码来源:hdf5_storage_test.py


示例5: test_store_and_load_large_dictionary

    def test_store_and_load_large_dictionary(self):
        traj = Trajectory(name='Test', filename=make_temp_file('large_dict.hdf5'))

        large_dict = {}

        for irun in range(1025):
            large_dict['item_%d' % irun] = irun

        large_dict2 = {}

        for irun in range(33):
            large_dict2['item_%d' % irun] = irun

        traj.f_add_result('large_dict', large_dict, comment='Huge_dict!')
        traj.f_add_result('large_dict2', large_dict2, comment='Not so large dict!')

        traj.f_store()

        traj_name = traj.v_name

        traj2 = Trajectory(filename=make_temp_file('large_dict.hdf5'))

        traj2.f_load(name=traj_name, load_all=2)

        self.compare_trajectories(traj, traj2)
开发者ID:lsolanka,项目名称:pypet,代码行数:25,代码来源:hdf5_storage_test.py


示例6: test_root_getting

    def test_root_getting(self):

        traj = Trajectory()

        traj.f_add_config_group('ff')

        root = traj.ff.f_get_root()

        self.assertTrue(root is traj)
开发者ID:lsolanka,项目名称:pypet,代码行数:9,代码来源:trajectory_test.py


示例7: test_storage_service_errors

    def test_storage_service_errors(self):

        traj = Trajectory(filename=make_temp_file('testnoservice.hdf5'))

        traj_name = traj.v_name

        # you cannot store stuff before the trajectory was stored once:
        with self.assertRaises(ValueError):
            traj.v_storage_service.store('FAKESERVICE', self, trajectory_name = traj.v_name)


        traj.f_store()

        with self.assertRaises(ValueError):
            traj.v_storage_service.store('FAKESERVICE', self, trajectory_name = 'test')

        with self.assertRaises(pex.NoSuchServiceError):
            traj.v_storage_service.store('FAKESERVICE', self, trajectory_name = traj.v_name)

        with self.assertRaises(ValueError):
            traj.f_load(name = 'test', index=1)

        with self.assertRaises(RuntimeError):
            traj.v_storage_service.store('LIST', [('LEAF',None,None,None,None)], trajectory_name = traj.v_name)

        with self.assertRaises(ValueError):
            traj.f_load(index=9999)

        with self.assertRaises(ValueError):
            traj.f_load(name='Non-Existising-Traj')
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:30,代码来源:hdf5_storage_test.py


示例8: test_net

    def test_net(self):
        self.env.f_run(run_net)

        self.traj.f_load(load_derived_parameters=2, load_results=2)

        traj2 = Trajectory(name = self.traj.v_name, add_time=False,
                           filename=make_temp_file('experiments/tests/briantests/HDF5/briantest.hdf5'),
                           dynamically_imported_classes=['pypet.brian.parameter.BrianParameter',
                                                        BrianMonitorResult])

        traj2.f_load(load_parameters=2, load_derived_parameters=2, load_results=2)

        self.compare_trajectories(self.traj, traj2)
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:13,代码来源:brian_full_network_test.py


示例9: test_run

    def test_run(self):
        self.env.f_run(dostuff_and_add_links)

        self.traj.f_load(load_data=2)

        traj2 = Trajectory()

        traj2.f_load(name=self.traj.v_name, filename=self.filename)

        traj2.f_load(load_data=2)

        for run in self.traj.f_get_run_names():
            self.assertTrue(self.traj.res.runs[run].paraBL is self.traj.paramB)

        self.compare_trajectories(self.traj, traj2)
开发者ID:SmokinCaterpillar,项目名称:pypet,代码行数:15,代码来源:link_test.py


示例10: test_not_adding_pars_during_single_run

    def test_not_adding_pars_during_single_run(self):
        traj = Trajectory()

        traj._is_run = True

        with self.assertRaises(TypeError):
            traj.f_add_parameter('dd')

        with self.assertRaises(TypeError):
            traj.f_add_parameter_group('dd')

        with self.assertRaises(TypeError):
            traj.f_add_config('dd')

        with self.assertRaises(TypeError):
            traj.f_add_config_group('dd')
开发者ID:lsolanka,项目名称:pypet,代码行数:16,代码来源:trajectory_test.py


示例11: test_illegal_namings

    def test_illegal_namings(self):
        self.traj=Trajectory('resulttest2')

        with self.assertRaises(ValueError):
            self.traj.f_add_parameter('f_get')

        with self.assertRaises(ValueError):
            self.traj.f_add_result('test.$.k.$')

        rg=self.traj.f_add_result_group('ggg.$')
        with self.assertRaises(ValueError):
            rg.f_add_result('$.fff')

        self.traj.f_add_result_group('test.$.k')
        with self.assertRaises(ValueError):
            self.traj.res.k.f_add_result('$.jjj')

        with self.assertRaises(ValueError):
            self.traj.f_add_parameter('e'*129)

        with self.assertRaises(ValueError):
            self.traj.f_add_parameter('e'*120+'.j'*120+'.k'*40)


        with self.assertRaises(ValueError):
            self.traj.f_add_parameter('crun',22)
开发者ID:lsolanka,项目名称:pypet,代码行数:26,代码来源:trajectory_test.py


示例12: test_short_cuts

    def test_short_cuts(self):

        self.traj = Trajectory()

        self.traj.f_add_parameter('test', 42)

        self.traj.f_add_config('tefffst', 42)

        self.traj.f_add_derived_parameter('dtest', 42)

        self.traj.f_add_result('safd', 42)

        self.traj.f_explore({'test':[1,2,3,4]})

        self.assertEqual(id(self.traj.par), id(self.traj.parameters))
        #self.assertEqual(id(self.traj.param), id(self.traj.parameters))


        self.assertEqual(id(self.traj.dpar), id(self.traj.derived_parameters))
        #self.assertEqual(id(self.traj.dparam), id(self.traj.derived_parameters))

        self.assertEqual(id(self.traj.conf), id(self.traj.config))

        self.assertEqual(id(self.traj.res), id(self.traj.results))


        srun = self.traj._make_single_run(3)

        srun.f_add_result('sdffds',42)


        self.assertEqual(id(srun.results.crun), id(srun.results.f_get(srun.v_name)))
开发者ID:lsolanka,项目名称:pypet,代码行数:32,代码来源:trajectory_test.py


示例13: test_loading

def test_loading(filenames, traj_names):

    loading_times = np.zeros(len(traj_names))
    loading_times_wd = np.zeros(len(traj_names))

    n_groups= np.zeros(len(traj_names), dtype='int')

    for idx, traj_name in enumerate(traj_names):
        filename = filenames[idx]
        traj = Trajectory(name=traj_name, filename=filename, add_time=False)
        start = time.time()
        traj.f_load(load_parameters=2, load_results=1, load_derived_parameters=1)
        elapsed = (time.time() - start)
        loading_times[idx]=elapsed

        n_groups[idx] = len([x for x in traj.f_iter_nodes(recursive=True)])
        del traj

        traj = Trajectory(name=traj_name, filename=filename, add_time=False)
        start = time.time()
        traj.f_load(load_all=2)
        elapsed = (time.time() - start)
        loading_times_wd[idx]=elapsed

    for idx, loading_time in enumerate(loading_times):
        loading_time_wd = loading_times_wd[idx]
        groups = n_groups[idx]
        print('Groups: %d, Loading: %.3fs, with Data: %.3fs' % (groups, loading_time, loading_time_wd))
开发者ID:lsolanka,项目名称:pypet,代码行数:28,代码来源:speed_test.py


示例14: test_net

    def test_net(self):
        self.env.f_run(run_net)

        self.traj.f_load(load_derived_parameters=2, load_results=2)

        traj2 = Trajectory(name = self.traj.v_name, add_time=False,
                           filename=make_temp_dir(os.path.join(
                               'experiments',
                               'tests',
                               'briantests',
                               'HDF5',
                               'briantest.hdf5')),
                           dynamic_imports=['pypet.brian.parameter.BrianParameter',
                                                        BrianMonitorResult])

        traj2.f_load(load_parameters=2, load_derived_parameters=2, load_results=2)

        self.compare_trajectories(self.traj, traj2)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:18,代码来源:brian_full_network_test.py


示例15: test_attribute_error_raises_when_leaf_and_group_with_same_name_are_added

    def test_attribute_error_raises_when_leaf_and_group_with_same_name_are_added(self):

        self.traj = Trajectory()

        self.traj.f_add_parameter('test.param1')

        with self.assertRaises(AttributeError):
            self.traj.f_add_parameter('test.param1.param2')

        with self.assertRaises(AttributeError):
            self.traj.f_add_parameter('test')
开发者ID:lsolanka,项目名称:pypet,代码行数:11,代码来源:trajectory_test.py


示例16: test_remov_of_explored_stuff_if_not_saved

    def test_remov_of_explored_stuff_if_not_saved(self):

        self.traj = Trajectory()

        self.traj.f_add_parameter('test', 42)

        self.traj.f_explore({'test':[1,2,3,4]})

        self.traj.parameters.f_remove_child('test')

        self.assertTrue(len(self.traj) == 1)
开发者ID:lsolanka,项目名称:pypet,代码行数:11,代码来源:trajectory_test.py


示例17: test_storage_and_loading

    def test_storage_and_loading(self):
        self.traj.f_store()

        traj_name = self.traj.v_name

        del self.traj

        self.traj = Trajectory(filename=self.filename)

        self.traj.f_load(name=traj_name, load_results=2, load_parameters=2, load_derived_parameters=2,
                         load_other_data=2)

        self.test_annotations_insert()
开发者ID:ilonajulczuk,项目名称:pypet,代码行数:13,代码来源:annotations_test.py


示例18: test_pipeline

    def test_pipeline(self):

        filename = 'testpostprocpipe.hdf5'
        env1, filename, _, _ = self.make_environment(filename, 'k1')
        env2 = self.make_environment(filename, 'k2', log=False)[0]

        traj1 = env1.v_trajectory
        traj2 = env2.v_trajectory

        trajs = [traj1, traj2]


        traj2.f_add_parameter('x', 1, comment='1st')
        traj2.f_add_parameter('y', 1, comment='1st')

        exp_dict2 = {'x':[1, 2, 3, 4, 1, 2, 2, 3],
                     'y':[1, 2, 3, 4, 1, 2, 0, 1]}

        traj2.f_explore(exp_dict2)


        res1 = env1.f_pipeline(pipeline=mypipeline)

        self.are_results_in_order(res1)

        res2 = env2.f_run(Multiply(), 22)

        self.are_results_in_order(res2)

        traj_name = traj1.v_name
        traj1 = Trajectory(traj_name, add_time=False, filename=filename)

        traj1.f_load(load_data=2)
        traj2.f_load(load_data=2)

        self.compare_trajectories(traj1, traj2)

        env1.f_disable_logging()
        env2.f_disable_logging()
开发者ID:MehmetTimur,项目名称:pypet,代码行数:39,代码来源:pipeline_test.py


示例19: test_remove_of_explored_stuff_if_saved

    def test_remove_of_explored_stuff_if_saved(self):

        self.traj = Trajectory()

        self.traj.f_add_parameter('test', 42)

        self.traj.f_explore({'test':[1,2,3,4]})

        self.traj._stored=True

        self.traj.parameters.f_remove_child('test')

        len(self.traj) == 4
开发者ID:lsolanka,项目名称:pypet,代码行数:13,代码来源:trajectory_test.py


示例20: profile_single_storing

def profile_single_storing(profile_stroing=False, profile_loading=True):

    logging.basicConfig(level = logging.INFO)

    logfolder = os.path.join(tempfile.gettempdir(), TEMPDIR, 'logs')
    pathfolder = os.path.join(tempfile.gettempdir(), TEMPDIR, 'hdf5')

    res_per_run = 100

    env = Environment(log_folder=logfolder, filename=pathfolder,
                      ncores=2, multiproc=False,
                      use_pool=True,
                      wrap_mode='QUEUE')

    traj = env.v_trajectory

    traj.f_add_parameter('res_per_run', res_per_run)
    traj.f_add_parameter('trial', 0)

    traj.f_explore({'trial':list(range(10))})

    runexp = lambda : env.f_run(add_data)


    if profile_stroing:
        cProfile.runctx('runexp()', {'runexp': runexp},globals(), sort=1,
                        filename='store_stats.profile')
    else:
        runexp()

    print('########################################################################')

    traj = Trajectory(name=traj.v_name, add_time=False, filename= traj.v_storage_service.filename)

    load = lambda : traj.f_load(load_parameters=2, load_results=1)

    if profile_loading:
        cProfile.runctx('load()', {'load': load},globals(), filename='load_stats.profile', sort=1)
开发者ID:lsolanka,项目名称:pypet,代码行数:38,代码来源:speed_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python comparisons.nested_equal函数代码示例发布时间:2022-05-27
下一篇:
Python ioutils.run_suite函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap