本文整理汇总了Python中gauge.Gauge.forget_past方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.forget_past方法的具体用法?Python Gauge.forget_past怎么用?Python Gauge.forget_past使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauge.Gauge
的用法示例。
在下文中一共展示了Gauge.forget_past方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_case8_simple
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import forget_past [as 别名]
def test_case8_simple():
max_ = Gauge(10, 10, at=0)
max_.add_momentum(-1)
g = Gauge(10, max_, at=0)
max_.forget_past(at=2)
with pytest.raises(ValueError):
max_.forget_past(at=1) # forget older past.
assert g.get(99999) == approx(0)
示例2: test_forget_past
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import forget_past [as 别名]
def test_forget_past():
g = Gauge(0, 50, at=0)
g.add_momentum(+1, since=0, until=5)
g.add_momentum(0, since=0)
g.add_momentum(0, until=999)
assert g.get(0) == 0
assert g.get(1) == 1
assert g.get(2) == 2
assert g.get(3) == 3
assert g.get(4) == 4
assert g.get(5) == 5
assert g.get(10) == 5
assert g.get(20) == 5
assert len(g.momenta) == 3
g.forget_past(at=30)
assert len(g.momenta) == 2
示例3: test_forget_past_before_base_time
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import forget_past [as 别名]
def test_forget_past_before_base_time():
g = Gauge(0, 100, at=100)
g.add_momentum(+1)
assert g.get(100) == 0
assert g.get(150) == 50
assert g.get(200) == 100
with pytest.raises(ValueError):
g.forget_past(at=50)
assert g.get(100) == 0
assert g.get(150) == 50
assert g.get(200) == 100
g.forget_past(at=150)
assert g.get(100) == 50
assert g.get(150) == 50
assert g.get(200) == 100
with pytest.raises(ValueError):
g.forget_past(0, at=100)
assert g.get(100) == 50
assert g.get(150) == 50
assert g.get(200) == 100
示例4: test_case8
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import forget_past [as 别名]
def test_case8():
"""There's a hyper-gauge. When the same effects are affected twice, the
underlying gauge became to be out of the limited range.
"""
m = Gauge(679, 679, at=1503918965.158631)
m.add_momentum(+0.001157)
g = Gauge(679, m, at=1503918965.158631)
g.add_momentum(+1)
# Gauge "g" should be always in the range of "m".
def G_SHOULD_BE_FULLY_IN_RANGE():
assert g.determination.in_range_since == g.base[TIME]
G_SHOULD_BE_FULLY_IN_RANGE()
# first effect ------------------------------------------------------------
m.forget_past(at=1503919261.248346)
G_SHOULD_BE_FULLY_IN_RANGE()
m.add_momentum(0, since=1503919261.248346, until=1503919266.248346)
m.forget_past(at=1503919261.248346)
G_SHOULD_BE_FULLY_IN_RANGE()
m.add_momentum(-0.2, since=1503919261.248346, until=1503919561.248346)
G_SHOULD_BE_FULLY_IN_RANGE()
# second effect -----------------------------------------------------------
m.forget_past(at=1503919279.381339)
G_SHOULD_BE_FULLY_IN_RANGE()
m.forget_past(at=1503919279.381339)
G_SHOULD_BE_FULLY_IN_RANGE()
m.add_momentum(0, since=1503919279.381339, until=1503919284.381339)
G_SHOULD_BE_FULLY_IN_RANGE()
m.forget_past(at=1503919279.482356)
m.remove_momentum(-0.2, since=1503919261.248346, until=1503919561.248346)
G_SHOULD_BE_FULLY_IN_RANGE()
with pytest.raises(ValueError):
m.forget_past(at=1503919279.381339)
m.add_momentum(-0.2, since=1503919279.381339, until=1503919579.381339)
G_SHOULD_BE_FULLY_IN_RANGE() # failing!
m.forget_past(at=1503919287.680848)
G_SHOULD_BE_FULLY_IN_RANGE() # failing!