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


Python Trajectory.parameters方法代码示例

本文整理汇总了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')
开发者ID:henribunting,项目名称:pypet,代码行数:33,代码来源:example_15_more_ways_to_add_data.py


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