本文整理汇总了Python中pypet.Trajectory.parameters方法的典型用法代码示例。如果您正苦于以下问题:Python Trajectory.parameters方法的具体用法?Python Trajectory.parameters怎么用?Python Trajectory.parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypet.Trajectory
的用法示例。
在下文中一共展示了Trajectory.parameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parameter
# 需要导入模块: from pypet import Trajectory [as 别名]
# 或者: from pypet.Trajectory import parameters [as 别名]
# 1st the standard way:
traj.f_add_parameter('x', 1, comment='I am the first dimension!')
# 2nd by providing a new parameter/result instance, be aware that the data is added where
# you specify it. There are no such things as shortcuts for parameter creation:
traj.parameters.y = Parameter('y', 1, comment='I am the second dimension!')
# 3rd as before, but if our new leaf has NO name it will be renamed accordingly:
traj.parameters.t = Parameter('', 1, comment='Third dimension')
# See:
print('t=' + str(traj.t))
# What happens if our new parameter's name does not match the name passed to the constructor?
traj.parameters.subgroup = Parameter('v', 2, comment='Fourth dimension')
# Well, since 'subgroup' != 'v', 'subgroup' becomes just another group node created on the fly
print(traj.parameters.subgroup)
# This even works for already existing groups and with the well known *dot* notation:
traj.parameters = Parameter('subgroup.subsubgroup.w', 2)
# See
print('w='+str(traj.par.subgroup.subsubgroup.w))
# There's a lazy version which does not require a constructor.
# This can be turned on via
traj.v_lazy_adding = True
# And you can add a new parameter via
traj.parameters.u = 1, 'Fourth dimension'
print('u=' + str(traj.u))
# However, now you can no longer change values of existing parameters,
# because this is interpreted as a new parameter addition, so this fails:
try:
traj.parameters.u = 2
print('I won`t be reached')