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


Python Gauge.set方法代码示例

本文整理汇总了Python中gauge.Gauge.set方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.set方法的具体用法?Python Gauge.set怎么用?Python Gauge.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gauge.Gauge的用法示例。


在下文中一共展示了Gauge.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_hypergauge_case3

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [as 别名]
def test_hypergauge_case3():
    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(10, at=0)
    g.set(12, outbound=OK, at=0)
    assert g.determination == [
        (0, 12), (1, 12), (3, 12), (5, 10), (6, 10), (8, 8)]
    g.set_max(Gauge(10, 100, at=0), at=0)
    assert g.determination == [
        (0, 12), (1, 12), (3, 12), (5, 10), (6, 10), (8, 8)]
开发者ID:what-studio,项目名称:gauge,代码行数:13,代码来源:gaugetest.py

示例2: test_decr_max_normal

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [as 别名]
def test_decr_max_normal():
    g = Gauge(0, 10, at=0)
    g.add_momentum(+2)
    g.add_momentum(-1)
    assert g.base[TIME] == 0
    assert g.get(10) == 10
    g.set_max(5, at=10)
    g.set(10, outbound=OK, at=10)
    assert g.base[TIME] == 10
    assert g.get(10) == 10
    assert g.get(15) == 5
    assert g.get(20) == 5
开发者ID:what-studio,项目名称:gauge,代码行数:14,代码来源:gaugetest.py

示例3: test_clear_momenta

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [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
开发者ID:what-studio,项目名称:gauge,代码行数:17,代码来源:gaugetest.py

示例4: test_clamped_by_max_gauge

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [as 别名]
def test_clamped_by_max_gauge():
    # in_range, decr max -> clamp
    g = Gauge(10, Gauge(20, 20, at=0), at=0)
    assert g.get(0) == 10
    g.max_gauge.set(5, at=0)
    assert g.get(0) == 5
    # in_range, incr max -> not clamp
    g.max_gauge.set(15, at=0)
    assert g.get(0) == 5
    # outbound, decr max -> not clamp
    g.set(20, outbound=OK, at=0)
    assert g.get(0) == 20
    g.max_gauge.set(10, at=0)
    assert g.get(0) == 20
    # time-skewed
    g = Gauge(10, Gauge(20, 20, at=0), at=0)
    g.max_gauge.set(5, at=10)
    assert g.base[TIME] == 10
    assert g.base[VALUE] == 5
开发者ID:what-studio,项目名称:gauge,代码行数:21,代码来源:gaugetest.py

示例5: test_clamp_outbound

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [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
开发者ID:what-studio,项目名称:gauge,代码行数:25,代码来源:gaugetest.py

示例6: test_over_max_on_hypergauge

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [as 别名]
def test_over_max_on_hypergauge():
    g = Gauge(1, Gauge(10, 20, at=0), at=0)
    g.max_gauge.add_momentum(+1)
    with pytest.raises(ValueError):
        g.set(20, at=0)
    g.set(20, at=0, outbound=OK)
    assert g.get(at=0) == 20
    g.set(20, at=10)
    assert g.get(at=10) == 20
    assert g.get(at=0) == 20  # past was forgot
开发者ID:what-studio,项目名称:gauge,代码行数:12,代码来源:gaugetest.py

示例7: test_ok_outbound

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set [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
开发者ID:what-studio,项目名称:gauge,代码行数:14,代码来源:gaugetest.py


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