本文整理汇总了Python中pypet.Trajectory.f_store_item方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_store_item方法的具体用法?Python Trajectory.f_store_item怎么用?Python Trajectory.f_store_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_store_item方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_file_size_many_params
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_store_item [as 别名]
def test_file_size_many_params(self):
filename = make_temp_dir('filesize.hdf5')
traj = Trajectory(filename=filename, overwrite_file=True, add_time=False)
npars = 700
traj.f_store()
for irun in range(npars):
par = traj.f_add_parameter('test.test%d' % irun, 42+irun, comment='duh!')
traj.f_store_item(par)
size = os.path.getsize(filename)
size_in_mb = size/1000000.
get_root_logger().info('Size is %sMB' % str(size_in_mb))
self.assertTrue(size_in_mb < 10.0, 'Size is %sMB > 10MB' % str(size_in_mb))
示例2: test_overwrite_stuff
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_store_item [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)
示例3: test_storing_and_loading_groups
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_store_item [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)
示例4: print
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import f_store_item [as 别名]
# 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
print('The object found for luke_skywalker is `%s`.' % str(traj.luke_skywalker))
#Let's store the trajectory:
traj.f_store()
# That was easy, let's assume we already completed a simulation and now we add a veeeery large
# result that we want to store to disk immediately and than empty it
traj.f_add_result('starwars.gross_income_of_film', amount=10.1 ** 11, currency='$$$',
comment='George Lucas is rich, dude!')
# This is a large number, we better store it and than free the memory:
traj.f_store_item('gross_income_of_film')
traj.gross_income_of_film.f_empty()
# Now lets reload the trajectory
del traj
traj = Trajectory(filename=filename)
# We want to load the last trajectory in the file, therefore index = -1
# We want to load the parameters, therefore load_parameters=2
# We only want to load the skeleton of the results, so load_results=1
traj.f_load(index=-1, load_parameters=2, load_results=1)
# Let's check if our result is really empty
if traj.gross_income_of_film.f_is_empty():
print('Nothing there!')
else: