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


Python Gauge.set_min方法代码示例

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


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

示例1: Equilibrium

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

示例2: test_repr

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set_min [as 别名]
def test_repr():
    g = Gauge(0, 10, at=0)
    assert repr(g) == '<Gauge 0.00/10.00>'
    g.set_min(-10, at=0)
    assert repr(g) == '<Gauge 0.00 between -10.00~10.00>'
    g.set_max(Gauge(10, 10), at=0)
    assert repr(g) == '<Gauge 0.00 between -10.00~<Gauge 10.00/10.00>>'
    m = Momentum(+100, since=10, until=20)
    assert repr(m) == '<Momentum +100.00/s 10.00~20.00>'
    m = Momentum(+100, since=10)
    assert repr(m) == '<Momentum +100.00/s 10.00~>'
    m = Momentum(+100, until=20)
    assert repr(m) == '<Momentum +100.00/s ~20.00>'
    h = Horizon(10, 20, 30)
    assert repr(h) == '<Line[HORIZON] 30.00 for 10.00~20.00>'
    r = Ray(10, 20, 30, 40)
    assert repr(r) == '<Line[RAY] 30.00+40.00/s for 10.00~20.00>'
开发者ID:what-studio,项目名称:gauge,代码行数:19,代码来源:gaugetest.py

示例3: test_set_min_max

# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import set_min [as 别名]
def test_set_min_max():
    # without momentum
    g = Gauge(5, 10)
    assert g.get_max() == 10
    assert g.get_min() == 0
    assert g.get() == 5
    g.set_range(max=100, min=10)
    assert g.get_max() == 100
    assert g.get_min() == 10
    assert g.get() == 10
    g.set_min(10)
    assert g.get() == 10
    g.set_min(5)
    assert g.get() == 10
    g.set_range(max=5, min=0)
    assert g.get_max() == 5
    assert g.get_min() == 0
    assert g.get() == 5
    # with momentum
    g = Gauge(5, 10, at=0)
    g.add_momentum(+1)
    assert g.determination == [(0, 5), (5, 10)]
    g.set_max(50, at=0)
    assert g.determination == [(0, 5), (45, 50)]
    g.set_min(40, at=0)
    assert g.determination == [(0, 40), (10, 50)]
开发者ID:what-studio,项目名称:gauge,代码行数:28,代码来源:gaugetest.py


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