本文整理汇总了Python中gauge.Gauge.decr方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.decr方法的具体用法?Python Gauge.decr怎么用?Python Gauge.decr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauge.Gauge
的用法示例。
在下文中一共展示了Gauge.decr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ok_outbound
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import decr [as 别名]
def test_ok_outbound():
g = Gauge(1, 10)
with pytest.raises(ValueError):
g.set(11)
with pytest.raises(ValueError):
g.incr(100)
with pytest.raises(ValueError):
g.decr(100)
g.set(10)
assert g.get() == 10
g.set(11, outbound=OK)
assert g.get() == 11
示例2: test_momenta_order
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import decr [as 别名]
def test_momenta_order():
g = Gauge(0, 50, at=0)
g.add_momentum(+3, since=0, until=5)
g.add_momentum(+2, since=1, until=4)
g.add_momentum(+1, since=2, until=3)
assert g.get(0) == 0
assert g.get(1) == 3
assert g.get(2) == 8
assert g.get(3) == 14
g.decr(1, at=3)
assert g.get(3) == 13
assert g.get(4) == 18
assert g.get(5) == 21
示例3: test_clamp_outbound
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import decr [as 别名]
def test_clamp_outbound():
g = Gauge(1, 10)
g.set(11, outbound=CLAMP)
assert g.get() == 10
g.incr(100, outbound=CLAMP)
assert g.get() == 10
g.decr(100, outbound=CLAMP)
assert g.get() == 0
g.incr(3, outbound=CLAMP)
assert g.get() == 3
g.decr(1, outbound=CLAMP)
assert g.get() == 2
g.set(100, outbound=OK)
g.incr(3, outbound=CLAMP)
assert g.get() == 100
g.decr(3, outbound=CLAMP)
assert g.get() == 97
g.set(98, outbound=CLAMP)
assert g.get() == 97
g.set(97, outbound=CLAMP)
assert g.get() == 97
g.set(96, outbound=CLAMP)
assert g.get() == 96