本文整理汇总了Python中param.parameterized.ParamOverrides.generator方法的典型用法代码示例。如果您正苦于以下问题:Python ParamOverrides.generator方法的具体用法?Python ParamOverrides.generator怎么用?Python ParamOverrides.generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类param.parameterized.ParamOverrides
的用法示例。
在下文中一共展示了ParamOverrides.generator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from param.parameterized import ParamOverrides [as 别名]
# 或者: from param.parameterized.ParamOverrides import generator [as 别名]
def __call__(self,**params_to_override):
p=ParamOverrides(self,params_to_override)
if self.time_fn() >= self.last_time + p.reset_period:
## Returns early if within episode interval
if self.time_fn()<self.last_time+p.reset_period+p.episode_interval:
return p.episode_separator(xdensity=p.xdensity,
ydensity=p.ydensity,
bounds=p.bounds)
else:
self._advance_params()
# JABALERT: Does not allow x, y, or direction to be passed in
# to the call; fixing this would require implementing
# inspect_value and force_new_dynamic_value (for
# use in _advance_params) for ParamOverrides.
#
# Access parameter values without giving them new values
assert ('x' not in params_to_override and
'y' not in params_to_override and
'direction' not in params_to_override)
x = self.inspect_value('x')
y = self.inspect_value('y')
direction = self.inspect_value('direction')
# compute how much time elapsed from the last reset
# float(t) required because time could be e.g. gmpy.mpq
t = float(self.time_fn()-self.last_time)
## CEBALERT: mask gets applied twice, both for the underlying
## generator and for this one. (leads to redundant
## calculations in current lissom_oo_or usage, but will lead
## to problems/limitations in the future).
return p.generator(
xdensity=p.xdensity,ydensity=p.ydensity,bounds=p.bounds,
x=x+t*np.cos(direction)*p.speed+p.generator.x,
y=y+t*np.sin(direction)*p.speed+p.generator.y,
orientation=(direction-pi/2)+p.generator.orientation)