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


Python Trajectory.f_load方法代码示例

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


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

示例1: test_partially_delete_stuff

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_partially_delete_stuff(self):
        traj = Trajectory(name='TestDelete',
                          filename=make_temp_dir('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)

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

示例2: test_overwrite_stuff

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_overwrite_stuff(self):
        traj = Trajectory(name='TestOverwrite', filename=make_temp_dir('testowrite.hdf5'))

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

        traj.f_store()

        res['a'] = np.array([1,2,3])
        res['c'] = 123445

        traj.f_store_item(res, overwrite='a', complevel=4)

        # Should emit a warning
        traj.f_store_item(res, overwrite=['a', 'b'])

        traj.f_load(load_results=3)

        res = traj.test

        self.assertTrue((res['a']==np.array([1,2,3])).all())
        self.assertTrue(res['c']=='d')

        res['c'] = 123445

        traj.f_store_item(res, store_data=3)
        res.f_empty()

        traj.f_load(load_results=3)

        self.assertTrue(traj.test['c']==123445)
开发者ID:henribunting,项目名称:pypet,代码行数:32,代码来源:storage_test.py

示例3: test_store_items_and_groups

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

        traj = Trajectory(name='testtraj', filename=make_temp_dir('teststoreitems.hdf5'))

        traj.f_store()

        traj.f_add_parameter('group1.test',42, comment= 'TooLong' * pypetconstants.HDF5_STRCOL_MAX_COMMENT_LENGTH)

        traj.f_add_result('testres', 42)

        traj.group1.f_set_annotations(Test=44)

        traj.f_store_items(['test','testres','group1'])


        traj2 = Trajectory(name=traj.v_name, add_time=False,
                           filename=make_temp_dir('teststoreitems.hdf5'))

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

        traj.f_add_result('Im.stored.along.a.path', 43)
        traj.Im.stored.along.v_annotations['wtf'] =4444
        traj.res.f_store_child('Im.stored.along.a.path')


        traj2.res.f_load_child('Im.stored.along.a.path', load_data=2)

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

示例4: main

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

    filename = os.path.join('hdf5', 'Clustered_Network.hdf5')
    # If we pass a filename to the trajectory a new HDF5StorageService will
    # be automatically created
    traj = Trajectory(filename=filename,
                    dynamically_imported_classes=[BrianMonitorResult,
                                                  BrianParameter])

    # Let's create and fake environment to enable logging:
    env = Environment(traj, do_single_runs=False)


    # Load the trajectory, but onyl laod the skeleton of the results
    traj.f_load(index=-1, load_parameters=2, load_derived_parameters=2, load_results=1)

    # Find the result instances related to the fano factor
    fano_dict = traj.f_get_from_runs('mean_fano_factor', fast_access=False)

    # Load the data of the fano factor results
    ffs = fano_dict.values()
    traj.f_load_items(ffs)

    # Extract all values and R_ee values for each run
    ffs_values = [x.f_get() for x in ffs]
    Rees = traj.f_get('R_ee').f_get_range()

    # Plot average fano factor as a function of R_ee
    plt.plot(Rees, ffs_values)
    plt.xlabel('R_ee')
    plt.ylabel('Avg. Fano Factor')
    plt.show()

    # Finally disable logging and close all log-files
    env.disable_logging()
开发者ID:MehmetTimur,项目名称:pypet,代码行数:37,代码来源:plotff.py

示例5: test_delete_links

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

示例6: test_version_mismatch

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_version_mismatch(self):
        traj = Trajectory(name='TestVERSION', filename=make_temp_dir('testversionmismatch.hdf5'),
                          add_time=True)

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

        traj.f_add_result('testres', 42)

        traj.group1.f_set_annotations(Test=44)

        traj._version='0.1a.1'

        traj.f_store()

        traj2 = Trajectory(name=traj.v_name, add_time=False,
                           filename=make_temp_dir('testversionmismatch.hdf5'))

        with self.assertRaises(pex.VersionMismatchError):
            traj2.f_load(load_parameters=2, load_results=2)

        traj2.f_load(load_parameters=2, load_results=2, force=True)

        self.compare_trajectories(traj,traj2)

        get_root_logger().info('Mismatch testing done!')
开发者ID:femtotrader,项目名称:pypet,代码行数:27,代码来源:storage_test.py

示例7: test_store_and_load_large_dictionary

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_store_and_load_large_dictionary(self):
        traj = Trajectory(name='Testlargedict', filename=make_temp_dir('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_dir('large_dict.hdf5'))

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

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

示例8: load_trajectory

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
 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(filename=self.filename)
     newtraj.f_load(name=trajectory_name, index=trajectory_index, as_new=as_new,
                    load_parameters=2, load_derived_parameters=2, load_results=2,
                    load_other_data=2)
     return newtraj
开发者ID:henribunting,项目名称:pypet,代码行数:9,代码来源:shared_data_test.py

示例9: test_storing_and_manipulating

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_storing_and_manipulating(self):
        filename = make_temp_dir("hdf5manipulation.hdf5")
        traj = Trajectory(name=make_trajectory_name(self), filename=filename)
        trajname = traj.v_name

        thedata = np.zeros((1000, 1000))
        res = traj.f_add_result(SharedResult, "shared")
        myarray = SharedArray("array", res, trajectory=traj, add_to_parent=True)
        mytable = SharedTable("t1", res, trajectory=traj, add_to_parent=True)
        mytable2 = SharedTable("t2", res, trajectory=traj, add_to_parent=True)
        mytable3 = SharedTable("t3", res, trajectory=traj, add_to_parent=True)

        traj.f_store(only_init=True)
        myarray.create_shared_data(data=thedata)
        mytable.create_shared_data(first_row={"hi": compat.tobytes("hi"), "huhu": np.ones(3)})
        mytable2.create_shared_data(description={"ha": pt.StringCol(2, pos=0), "haha": pt.FloatCol(pos=1)})
        mytable3.create_shared_data(description={"ha": pt.StringCol(2, pos=0), "haha": pt.FloatCol(pos=1)})

        traj.f_store()

        newrow = {"ha": "hu", "haha": 4.0}

        with self.assertRaises(TypeError):
            row = traj.shared.t2.row

        with StorageContextManager(traj) as cm:
            row = traj.shared.t2.row
            for irun in range(11):
                for key, val in newrow.items():
                    row[key] = val
                row.append()
            traj.shared.t3.flush()

        data = myarray.read()
        arr = myarray.get_data_node()
        self.assertTrue(np.all(data == thedata))

        with StorageContextManager(traj) as cm:
            myarray[2, 2] = 10
            data = myarray.read()
            self.assertTrue(data[2, 2] == 10)

        self.assertTrue(data[2, 2] == 10)
        self.assertFalse(traj.v_storage_service.is_open)

        traj = load_trajectory(name=trajname, filename=filename)

        traj.f_load(load_data=2)

        traj.shared.t2.traj = traj
        traj.shared.t1.traj = traj
        traj.shared.array.traj = traj

        self.assertTrue(traj.shared.t2.nrows == 11, "%s != 11" % str(traj.shared.t2.nrows))
        self.assertTrue(traj.shared.t2[0]["ha"] == compat.tobytes("hu"), traj.shared.t2[0]["ha"])
        self.assertTrue(traj.shared.t2[1]["ha"] == compat.tobytes("hu"), traj.shared.t2[1]["ha"])
        self.assertTrue("huhu" in traj.shared.t1.colnames)
        self.assertTrue(traj.shared.array[2, 2] == 10)
开发者ID:MehmetTimur,项目名称:pypet,代码行数:60,代码来源:shared_data_test.py

示例10: test_loading_explored_parameters

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

        filename = make_temp_dir('load_explored.hdf5')
        traj = Trajectory(filename=filename, overwrite_file=True, add_time=False)
        traj.par.x = Parameter('x', 42, comment='answer')
        traj.f_explore({'x':[1,2,3,4]})
        traj.f_store()
        name = traj.v_name

        traj = Trajectory(filename=filename, add_time=False)
        traj.f_load()
        x = traj.f_get('x')
        self.assertIs(x, traj._explored_parameters['parameters.x'])
开发者ID:henribunting,项目名称:pypet,代码行数:15,代码来源:storage_test.py

示例11: test_max_depth_loading_and_storing

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_max_depth_loading_and_storing(self):
        filename = make_temp_dir('newassignment.hdf5')
        traj = Trajectory(filename=filename, overwrite_file=True)

        traj.par = Parameter('d1.d2.d3.d4.d5', 55)
        traj.f_store(max_depth=4)

        traj = load_trajectory(index=-1, filename=filename)
        traj.f_load(load_data=2)
        self.assertTrue('d3' in traj)
        self.assertFalse('d4' in traj)

        traj = load_trajectory(index=-1, filename=filename, max_depth=3)
        self.assertTrue('d2' in traj)
        self.assertFalse('d3' in traj)

        traj.par.f_remove(recursive=True)
        traj.dpar = Parameter('d1.d2.d3.d4.d5', 123)

        traj.dpar.f_store_child('d1', recursive=True, max_depth=3)
        traj.dpar.f_remove_child('d1', recursive=True)

        self.assertTrue('d1' not in traj)
        traj.dpar.f_load_child('d1', recursive=True)

        self.assertTrue('d3' in traj)
        self.assertTrue('d4' not in traj)

        traj.dpar.f_remove_child('d1', recursive=True)
        self.assertTrue('d1' not in traj)
        traj.dpar.f_load_child('d1', recursive=True, max_depth=2)

        self.assertTrue('d2' in traj)
        self.assertTrue('d3' not in traj)

        traj.dpar = Parameter('l1.l2.l3.l4.l5', 123)
        traj.dpar.f_store(recursive=True, max_depth=0)
        self.assertFalse(traj.dpar.l1._stored)

        traj.dpar.f_store(recursive=True, max_depth=4)
        traj.dpar.f_remove()
        self.assertTrue('l1' not in traj)
        traj.dpar.f_load(recursive=True)
        self.assertTrue('l4' in traj)
        self.assertTrue('l5' not in traj)

        traj.dpar.f_remove()
        self.assertTrue('l1' not in traj)
        traj.dpar.f_load(recursive=True, max_depth=3)
        self.assertTrue('l3' in traj)
        self.assertTrue('l4' not in traj)
开发者ID:henribunting,项目名称:pypet,代码行数:53,代码来源:storage_test.py

示例12: test_backwards_compatibility

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_backwards_compatibility(self):
        # Test only makes sense with python 2.7 or lower
        old_pypet_traj = Trajectory()
        module_path, init_file = os.path.split(pypet.__file__)
        filename= os.path.join(module_path, 'tests','testdata','pypet_v0_1b_6.hdf5')
        old_pypet_traj.f_load(index=-1, load_data=2, force=True, filename=filename)

        self.assertTrue(old_pypet_traj.v_version=='0.1b.6')
        self.assertTrue(old_pypet_traj.par.x==0)
        self.assertTrue(len(old_pypet_traj)==9)
        self.assertTrue(old_pypet_traj.res.runs.r_4.z==12)
        nexplored = len(old_pypet_traj._explored_parameters)
        self.assertGreater(nexplored, 0)
        for param in old_pypet_traj.f_get_explored_parameters():
            self.assertTrue(old_pypet_traj.f_contains(param))
开发者ID:femtotrader,项目名称:pypet,代码行数:17,代码来源:backwards_compat_test.py

示例13: test_storing_and_loading_groups

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [as 别名]
    def test_storing_and_loading_groups(self):
        filename = make_temp_dir('grpgrp.hdf5')
        traj = Trajectory(name='traj', add_time=True, filename=filename)
        res=traj.f_add_result('aaa.bbb.ccc.iii', 42, 43, comment=7777 * '6')
        traj.ccc.v_annotations['gg']=4
        res=traj.f_add_result('aaa.ddd.eee.jjj', 42, 43, comment=777 * '6')
        traj.ccc.v_annotations['j'] = 'osajdsojds'
        traj.f_store(only_init=True)
        traj.f_store_item('aaa', recursive=True)
        newtraj = load_trajectory(traj.v_name, filename=filename, load_all=2)

        self.compare_trajectories(traj, newtraj)

        traj.iii.f_set(55)

        self.assertFalse(results_equal(traj.iii, newtraj.iii))

        traj.aaa.f_store(recursive=True, store_data=3)

        newtraj.bbb.f_load(recursive=True, load_data=3)

        self.compare_trajectories(traj, newtraj)

        traj.ccc.v_annotations['gg'] = 5
        traj.f_load(load_data=3)
        self.assertTrue(traj.ccc.v_annotations['gg'] == 4)
        traj.ccc.v_annotations['gg'] = 5
        traj.f_store(store_data=3)
        newtraj.f_load(load_data=2)
        self.assertTrue(newtraj.ccc.v_annotations['gg'] == 4)
        newtraj.f_load(load_data=3)
        self.assertTrue(newtraj.ccc.v_annotations['gg'] == 5)

        traj.ccc.f_add_link('link', res)
        traj.f_store_item(traj.ccc, store_data=3, with_links=False)

        newtraj.f_load(load_data=3)
        self.assertTrue('link' not in newtraj.ccc)

        traj.f_store_item(traj.ccc, store_data=3, with_links=True, recursive=True)

        newtraj.f_load_item(newtraj.ccc, with_links=False, recursive=True)
        self.assertTrue('link' not in newtraj.ccc)

        newtraj.f_load_item(newtraj.ccc, recursive=True)
        self.assertTrue('link' in newtraj.ccc)
开发者ID:henribunting,项目名称:pypet,代码行数:48,代码来源:storage_test.py

示例14: test_link_deletion

# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_load [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

示例15: test_throw_warning_if_old_kw_is_used

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

        filename = make_temp_dir('hdfwarning.hdf5')

        with warnings.catch_warnings(record=True) as w:

            env = Environment(trajectory='test', filename=filename,
                              dynamically_imported_classes=[],
                              log_config=get_log_config())

        with warnings.catch_warnings(record=True) as w:
            traj = Trajectory(dynamically_imported_classes=[])

        traj = env.v_trajectory
        traj.f_store()

        with warnings.catch_warnings(record=True) as w:
            traj.f_load(dynamically_imported_classes=[])

        env.f_disable_logging()
开发者ID:henribunting,项目名称:pypet,代码行数:23,代码来源:storage_test.py


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