本文整理汇总了Python中pypet.trajectory.Trajectory.f_add_derived_parameter方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.f_add_derived_parameter方法的具体用法?Python Trajectory.f_add_derived_parameter怎么用?Python Trajectory.f_add_derived_parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.trajectory.Trajectory
的用法示例。
在下文中一共展示了Trajectory.f_add_derived_parameter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auto_load
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
def test_auto_load(self):
traj = Trajectory(name='Test', filename=make_temp_file('autoload.hdf5'))
traj.v_auto_load = True
traj.f_add_result('I.am.$.a.mean.resu', 42, comment='Test')
traj.f_add_derived_parameter('ffa', 42)
traj.f_store()
ffa=traj.f_get('ffa')
ffa.f_unlock()
ffa.f_empty()
self.assertTrue(ffa.f_is_empty())
traj.f_remove_child('results', recursive=True)
# check auto load
val = traj.res.I.am.crun.a.mean.resu
self.assertTrue(val==42)
val = traj.ffa
self.assertTrue(val==42)
with self.assertRaises(Exception):
traj.kdsfdsf
示例2: test_migrations
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
def test_migrations(self):
traj = Trajectory(name='Test', filename=make_temp_file('migrate.hdf5'))
traj.f_add_result('I.am.a.mean.resu', 42, comment='Test')
traj.f_add_derived_parameter('ffa', 42)
traj.f_store()
new_file = make_temp_file('migrate2.hdf5')
traj.f_migrate(new_filename=new_file)
traj.f_store()
new_traj = Trajectory()
new_traj.f_migrate(new_name=traj.v_name, new_filename=new_file, in_store=True)
new_traj.v_auto_load=True
self.assertTrue(new_traj.results.I.am.a.mean.resu == 42)
示例3: test_file_translation
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
def test_file_translation(self):
filename = make_temp_dir('to_new_tree.hdf5')
mytraj = Trajectory('SCRATCH', filename=filename)
mytraj.f_add_parameter('Test.Group.Test', 42)
mytraj.f_add_derived_parameter('trajectory.saaaa',33)
mytraj.f_add_derived_parameter('trajectory.intraj.dpar1',33)
mytraj.f_add_derived_parameter('run_00000008.inrun.dpar2',33)
mytraj.f_add_derived_parameter('run_00000001.inrun.dpar3',35)
mytraj.f_add_result('trajectory.intraj.res1',33)
mytraj.f_add_result('run_00000008.inrun.res1',33)
mytraj.f_store()
mytraj.f_migrate(new_name=mytraj.v_name + 'PETER', in_store=True)
mytraj.f_store()
fu=FileUpdater(filename=filename, backup=True)
fu.update_file()
mytraj = Trajectory(name=mytraj.v_name, add_time=False, filename=filename)
mytraj.f_load(load_parameters=2, load_derived_parameters=2, load_results=2)
for node in mytraj.f_iter_nodes():
self.assertTrue(node.v_name != 'trajectory')
if 'run_' in node.v_full_name:
self.assertTrue('.runs.' in node.v_full_name)
remove_data()
示例4: main
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
def main():
pool = Pool(2)
lock = Manager().Lock()
logging.basicConfig(level=logging.DEBUG)
log_to_stderr()
traj = Trajectory(name='MyTrajectory',filename='../experiments/test.hdf5')
config['multiproc'] = True
#traj.load_trajectory(trajectoryname='MyTrajectory_2013_05_23_14h29m26s')
traj.f_add_parameter('test.testparam', param_type=ParameterSet, **{'Fuechse':1,'Sapiens':1,'Comment':'ladida'})
traj.last.foo = 'bar'
traj.f_add_parameter('Network.Cm')
traj.Parameters.Network.Cm.value= 1.0
traj.Parameters.Network.Cm.unit = 'pF'
print traj.Parameters.Network.Cm()
traj.last.herbert = 4.5
traj.Parameters.test.testparam.Konstantin = 'Konstantin'
traj.f_add_parameter(full_parameter_name='honky', **{'mirta':np.array([[1,2,7],[3,2,17]])})
traj.f_add_parameter('flonky',**{'val' : 10})
param1 = traj.Parameters.test.testparam
param2 = traj.Parameters.honky
param3 = traj.last
print param1()
print param3('val')
exp2_list = range(3)
exp1_list = range(3)
exp3_list = range(3)
explore_dict = { param1.gfn('Sapiens') : exp1_list,
param2.get_fullname('mirta'):exp2_list,
param3.gfn('val') : exp3_list}
cmb_list=[(param3.gfn('val'),param1.gfn('Sapiens'))]
traj.f_add_derived_parameter(full_parameter_name='foo', **{'bar' : -1}).moo = 'zip'
lilma = spsp.lil_matrix((10000,1000))
lilma[0,100] = 555
lilma[9999,999] = 11
traj.f_add_parameter('sparse', mat=lilma, param_type = SparseParameter)
traj.f_explore(ut.cartesian_product,explore_dict,cmb_list)
traj._prepare_experiment()
traj.f_store()
pathname = config['logfolder']
it = ((traj._make_single_run(n),lock, pathname) for n in xrange(len(traj)))
moo = pool.imap(do_stuff, it)
pool.close()
pool.join()
示例5: TrajectoryMergeTest
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
class TrajectoryMergeTest(unittest.TestCase):
def setUp(self):
name = 'Moop'
self.traj = Trajectory(name,[ImAParameterInDisguise])
comment = 'This is a comment'
self.traj.v_comment=comment
self.assertTrue(comment == self.traj.v_comment)
self.traj.f_add_parameter('IntParam',3)
sparsemat = spsp.csr_matrix((1000,1000))
sparsemat[1,2] = 17.777
#self.traj.f_add_parameter('SparseParam', sparsemat, param_type=PickleParameter)
self.traj.f_add_parameter('FloatParam')
self.traj.f_add_derived_parameter(Parameter('FortyTwo', 42))
self.traj.f_add_parameter('Trials',0)
self.traj.f_add_result(Result,'Im.A.Simple.Result',44444)
self.traj.FloatParam=4.0
self.traj.v_storage_service = LazyStorageService()
self.traj.f_explore({'FloatParam':[1.0,1.1,1.2,1.3],'Trials':[0,1,2,3]})
self.assertTrue(len(self.traj) == 4)
name2 = 'aaaaah'
self.traj2 = Trajectory(name2,[ImAParameterInDisguise])
comment = 'This is a comment'
self.traj2.v_comment=comment
self.assertTrue(comment == self.traj2.v_comment)
self.traj2.f_add_parameter('IntParam',3)
sparsemat = spsp.csr_matrix((1000,1000))
sparsemat[1,2] = 17.777
#self.traj2.f_add_parameter('SparseParam', sparsemat, param_type=PickleParameter)
self.traj2.f_add_parameter('Trials',0)
self.traj2.f_add_parameter('FloatParam')
self.traj2.f_add_derived_parameter(Parameter('FortyTwo', 42))
self.traj2.f_add_result(Result,'Im.A.Simple.Result',44444)
self.traj2.FloatParam=4.0
self.traj2.f_explore({'FloatParam':[42.0,43.0,1.2,1.3],'Trials':[0,1,2,3]})
self.traj2.v_storage_service = LazyStorageService()
self.assertTrue(len(self.traj2) == 4)
def test_merge_parameters_without_remove(self):
# remove_duplicates = True should be discarded by the trial parameter
self.traj._merge_parameters(self.traj2, trial_parameter_name='Trials',remove_duplicates=True)
def test_merge_parameters_with_remove(self):
self.traj._merge_parameters(self.traj2,remove_duplicates=True)
def test_merge_without_remove(self):
self.traj.f_merge(self.traj2, remove_duplicates=True,trial_parameter='Trials')
def test_merge_with_remove(self):
self.traj.f_merge(self.traj2, remove_duplicates=True)
示例6: TrajectoryTest
# 需要导入模块: from pypet.trajectory import Trajectory [as 别名]
# 或者: from pypet.trajectory.Trajectory import f_add_derived_parameter [as 别名]
class TrajectoryTest(unittest.TestCase):
def setUp(self):
name = 'Moop'
self.traj = Trajectory(name,dynamically_imported_classes=[ImAParameterInDisguise,
'pypet.tests.test_helpers.ImAResultInDisguise'])
self.assertTrue(self.traj.f_is_empty())
comment = 'This is a comment'
self.traj.v_comment=comment
self.assertTrue(comment == self.traj.v_comment)
self.traj.f_add_parameter('IntParam',3)
sparsemat = spsp.csr_matrix((1000,1000))
sparsemat[1,2] = 17.777
self.traj.f_add_parameter(PickleParameter,'SparseParam', sparsemat)
self.traj.f_add_parameter('FloatParam')
self.traj.f_add_derived_parameter(Parameter('FortyTwo', 42))
self.traj.f_add_result(Result,'Im.A.Simple.Result',44444)
self.traj.FloatParam=4.0
self.explore_dict = {'FloatParam':[1.0,1.1,1.2,1.3]}
self.traj.f_explore(self.explore_dict)
self.assertTrue(len(self.traj) == 4)
self.traj.f_add_parameter_group('peter.paul')
self.traj.f_add_parameter('peter.markus.yve',6)
self.traj.f_add_result('Test',42)
self.traj.peter.f_add_parameter('paul.peter')
self.traj.f_add_config('make.impossible.promises',1)
with self.assertRaises(AttributeError):
self.traj.markus.peter
with self.assertRaises(ValueError):
self.traj.f_add_parameter('Peter. h ._hurz')
def test_shrink(self):
self.assertTrue(len(self.traj)>1)
self.traj.f_shrink()
self.assertTrue(len(self.traj)==1)
self.assertTrue(len(self.traj.f_get_explored_parameters())==0)
def test_get_all(self):
all_nodes = self.traj.f_get_all('peter')
self.assertTrue(len(all_nodes)==2)
all_nodes = self.traj.f_get_all('peter.yve')
self.assertTrue(len(all_nodes)==1)
all_nodes = self.traj.f_get_all('paul.yve')
self.assertTrue(len(all_nodes)==0)
self.traj.f_add_parameter('paul.paul')
all_nodes = self.traj.peter.f_get_all('paul')
self.assertTrue(len(all_nodes)==1)
self.traj.f_add_result('results.runs.run_00000000.x.y',10)
self.traj.f_add_result('results.runs.run_00000001.x.y',10)
self.traj.f_add_derived_parameter('hfhfhf.x.y')
self.traj.f_add_result('x.y.y')
self.traj.f_as_run(1)
all_nodes=self.traj.f_get_all('x.y')
self.assertTrue(len(all_nodes)==4)
def test_backwards_search(self):
x=self.traj.peter.f_get('paul.peter', backwards_search=False)
#.........这里部分代码省略.........