本文整理汇总了Python中gauge.Gauge.remove_momentum方法的典型用法代码示例。如果您正苦于以下问题:Python Gauge.remove_momentum方法的具体用法?Python Gauge.remove_momentum怎么用?Python Gauge.remove_momentum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gauge.Gauge
的用法示例。
在下文中一共展示了Gauge.remove_momentum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clear_momentum_events
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import remove_momentum [as 别名]
def test_clear_momentum_events():
g = Gauge(0, 10, at=0)
m = g.add_momentum(+1, since=10, until=20)
assert list(g.momentum_events()) == \
[(0, NONE, None), (10, ADD, m), (20, REMOVE, m), (+inf, NONE, None)]
# assert len(g._events) == 2
g.remove_momentum(m)
assert list(g.momentum_events()) == [(0, NONE, None), (+inf, NONE, None)]
示例2: test_remove_momentum_event_on_remove_momentum
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import remove_momentum [as 别名]
def test_remove_momentum_event_on_remove_momentum():
g = Gauge(0, 10, at=0)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
g.remove_momentum(+1)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
g.remove_momentum(+1)
g.add_momentum(+1)
g.add_momentum(+1)
assert g.determination == [(0, 0), (5, 10)]
g.clear_momenta(at=0)
g.add_momentum(+1)
assert g.determination == [(0, 0), (10, 10)]
示例3: test_case8
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import remove_momentum [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!
示例4: test_remove_momentum
# 需要导入模块: from gauge import Gauge [as 别名]
# 或者: from gauge.Gauge import remove_momentum [as 别名]
def test_remove_momentum():
g = Gauge(0, 10, at=0)
m1 = g.add_momentum(+1)
m2 = g.add_momentum(Momentum(+1))
g.add_momentum(+2, since=10)
g.add_momentum(-3, until=100)
assert len(g.momenta) == 4
assert g.remove_momentum(m2) == m2
assert len(g.momenta) == 3
assert m1 in g.momenta
assert m2 in g.momenta
assert g.remove_momentum(m2) == m2
assert len(g.momenta) == 2
assert m1 not in g.momenta
assert m2 not in g.momenta
with pytest.raises(ValueError):
g.remove_momentum(+2)
assert g.remove_momentum(+2, since=10) == (+2, 10, +inf)
assert len(g.momenta) == 1
assert g.remove_momentum(Momentum(-3, until=100)) == (-3, -inf, 100)
assert not g.momenta