本文整理汇总了Python中pypet.trajectory.Trajectory.f_load方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_load方法的具体用法?Python Trajectory.f_load怎么用?Python Trajectory.f_load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.trajectory.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_a_large_run
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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))
示例2: test_store_items_and_groups
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
def test_store_items_and_groups(self):
traj = Trajectory(name='testtraj', filename=make_temp_file('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_file('teststoreitems.hdf5'))
traj2.f_load(load_results=2,load_parameters=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)
示例3: test_partially_delete_stuff
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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)
示例4: test_store_and_load_large_dictionary
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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)
示例5: test_overwrite_stuff
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
def test_overwrite_stuff(self):
traj = Trajectory(name='Test', filename=make_temp_file('testowrite.hdf5'))
res = traj.f_add_result('mytest.test', a='b', c='d')
traj.f_store()
res['a'] = 333
res['c'] = 123445
traj.f_store_item(res, overwrite='a')
# 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']==333)
self.assertTrue(res['c']=='d')
res['c'] = 123445
traj.f_store_item(res, overwrite=True)
res.f_empty()
traj.f_load(load_results=3)
self.assertTrue(traj.test['c']==123445)
示例6: load_trajectory
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.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()
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
示例7: test_loading
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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))
示例8: test_net
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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)
示例9: test_run
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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)
示例10: test_store_load_with_hdf5
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
def test_store_load_with_hdf5(self):
traj_name = 'test_%s' % self.__class__.__name__
filename = make_temp_dir(traj_name + '.hdf5')
traj = Trajectory(name=traj_name, dynamic_imports=self.dynamic_imports,
filename = filename, overwrite_file=True)
for res in self.results.values():
traj.f_add_result(res)
traj.f_store()
new_traj = Trajectory(name=traj_name, dynamic_imports=self.dynamic_imports,
filename = filename)
new_traj.f_load(load_data=2)
self.compare_trajectories(traj, new_traj)
示例11: test_store_load_with_hdf5_no_data
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
def test_store_load_with_hdf5_no_data(self):
traj_name = 'test_%s' % self.__class__.__name__
filename = make_temp_dir(traj_name + 'nodata.hdf5')
traj = Trajectory(name=traj_name, dynamic_imports=self.dynamic_imports,
filename = filename, overwrite_file=True)
for param in self.param.values():
param._data = None
traj.f_add_parameter(param)
traj.f_store()
new_traj = Trajectory(name=traj_name, dynamic_imports=self.dynamic_imports,
filename = filename)
new_traj.f_load(load_data=2)
self.compare_trajectories(traj, new_traj)
示例12: test_net
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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)
示例13: test_storage_service_errors
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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')
示例14: test_pipeline
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
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()
示例15: main
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_load [as 别名]
def main():
folder = 'experiments/example_11/HDF5/'
filename = 'Clustered_Network.hdf5'
filename = os.path.join(folder, filename)
# If we pass a filename to the trajectory a new HDF5StorageService will
# be automatically created
traj = Trajectory(filename=filename,
dynamically_imported_classes=[BrianDurationParameter,
BrianMonitorResult,
BrianParameter])
# Let's create and fake environment to enable logging:
Environment(traj, do_single_runs=False)
# Load the trajectory, but onyl laod the skeleton of the results
traj.f_load(index=0, # Change if you do not want to load the very first trajectory
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()