本文整理汇总了Python中gauge.Gauge.incr方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.incr方法的具体用法?Python Gauge.incr怎么用?Python Gauge.incr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauge.Gauge
的用法示例。
在下文中一共展示了Gauge.incr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hypergauge_case4
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [as 别名]
def test_hypergauge_case4():
g = Gauge(12, 100, at=0)
g.add_momentum(+1, since=1, until=6)
g.add_momentum(-1, since=3, until=8)
g.set_max(Gauge(15, 15, at=0), at=0)
g.max_gauge.add_momentum(-1)
assert g.determination == [
(0, 12), (1, 12), (2, 13), (3, 12), (6, 9), (8, 7), (15, 0)]
# bidirectional hyper-gauge
g_max = Gauge(10, 10, at=0)
g_max.add_momentum(-1, since=0, until=4)
g_max.add_momentum(+1, since=6, until=7)
g_min = Gauge(0, 10, at=0)
g_min.add_momentum(+1, since=1, until=6)
g_min.add_momentum(-1, since=6, until=8)
g = Gauge(5, g_max, g_min, at=0)
g.add_momentum(+1, since=0, until=3)
g.add_momentum(-1, since=3, until=6)
g.add_momentum(+1, since=6, until=9)
g.add_momentum(-1, since=9, until=12)
assert g.determination == [
(0, 5), (2.5, 7.5), (3, 7), (4, 6), (5.5, 4.5), (6, 5), (8, 7),
(9, 7), (12, 4)]
g_min.incr(1, at=5)
assert g.determination == [(5, 5), (6, 6), (7, 7), (9, 7), (12, 4)]
示例2: test_ok_outbound
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [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
示例3: test_case3
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [as 别名]
def test_case3():
g = Gauge(0, 10, at=0)
assert g.get(0) == 0
g.add_momentum(+1, since=0)
assert g.get(10) == 10
g.incr(3, outbound=OK, at=11)
assert g.get(11) == 13
g.add_momentum(-1, since=13)
assert g.get(13) == 13
assert g.get(14) == 12
assert g.get(15) == 11
assert g.get(16) == 10
assert g.get(17) == 10
示例4: test_life
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [as 别名]
def test_life():
with t(0):
life = Gauge(100, 100)
life.add_momentum(-1)
assert life.get() == 100
with t(1):
assert life.get() == 99
with t(2):
assert life.get() == 98
with t(10):
assert life.get() == 90
life.incr(1)
assert life.get() == 91
with t(11):
assert life.get() == 90
示例5: test_clamp_outbound
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [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
示例6: test_once_outbound
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import incr [as 别名]
def test_once_outbound():
g = Gauge(1, 10)
assert g.incr(5, outbound=ONCE) == 6
assert g.incr(5, outbound=ONCE) == 11
with pytest.raises(ValueError):
g.incr(1, outbound=ONCE)