本文整理汇总了Python中gauge.Gauge.clear_momenta方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.clear_momenta方法的具体用法?Python Gauge.clear_momenta怎么用?Python Gauge.clear_momenta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauge.Gauge
的用法示例。
在下文中一共展示了Gauge.clear_momenta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_range
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import clear_momenta [as 别名]
def test_set_range():
g = Gauge(0, 100, at=0)
g.add_momentum(+1)
assert g.determination == [(0, 0), (100, 100)]
g.set_range(Gauge(100, 100, at=0), Gauge(0, 100, at=0), at=0)
g.max_gauge.add_momentum(-1, until=40)
g.min_gauge.add_momentum(+1, until=40)
assert g.determination == [(0, 0), (60, 60)]
g.clear_momenta(at=30)
g.add_momentum(-1)
assert g.determination == [(30, 30), (40, 40)]
示例2: test_remove_momentum_event_on_remove_momentum
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import clear_momenta [as 别名]
def test_remove_momentum_event_on_remove_momentum():
g = Gauge(0, 10, at=0)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
g.remove_momentum(+1)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
g.remove_momentum(+1)
g.add_momentum(+1)
g.add_momentum(+1)
assert g.determination == [(0, 0), (5, 10)]
g.clear_momenta(at=0)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
示例3: Equilibrium
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import clear_momenta [as 别名]
class Equilibrium(object):
gauge = None
speed = None
def __init__(self, medium, speed):
self.speed = speed
self.medium = medium
@property
def medium(self):
return self._medium
@medium.setter
def medium(self, medium, at=None):
at = now_or(at)
self._medium = medium
if self.gauge is None:
self.gauge = Gauge(medium, medium, medium)
return
value = self.gauge.clear_momenta(at)
if value == medium:
self.gauge._set_limits(medium, medium, at=at)
return
if value < medium:
self.gauge.set_max(medium, at=at)
velocity = +self.speed
elif value > medium:
self.gauge.set_min(medium, at=at)
velocity = -self.speed
self.gauge.add_momentum(velocity, since=at)
示例4: test_clear_momenta
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import clear_momenta [as 别名]
def test_clear_momenta():
g = Gauge(0, 10, at=0)
g.add_momentum(+1)
g.clear_momenta(at=5)
assert g.get(5) == 5
assert g.determination == [(5, 5)]
# clear momenta when the value is out of the range
g.add_momentum(+1)
g.set(15, outbound=OK, at=10)
g.clear_momenta(at=10)
assert g.get(10) == 15
assert g.determination == [(10, 15)]
# rebase by Gauge.clear_momenta()
g.clear_momenta(100)
assert g.get() == 100