本文整理匯總了Python中gnome.multi_model_broadcast.ModelBroadcaster.stop方法的典型用法代碼示例。如果您正苦於以下問題:Python ModelBroadcaster.stop方法的具體用法?Python ModelBroadcaster.stop怎麽用?Python ModelBroadcaster.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnome.multi_model_broadcast.ModelBroadcaster
的用法示例。
在下文中一共展示了ModelBroadcaster.stop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_timeout
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_timeout(secs, timeout, expected_runtime, valid_func):
model = make_model()
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
try:
print '\nsleeping for {} secs...'.format(secs)
if timeout is None:
begin = time.time()
res = model_broadcaster.cmd('sleep', {'secs': secs})
end = time.time()
else:
begin = time.time()
res = model_broadcaster.cmd('sleep', {'secs': secs},
timeout=timeout)
end = time.time()
rt = end - begin
# runtime duraton should be either:
# - the expected response time plus a bit of overhead
# - the expected timeout plus a bit of overhead
print 'runtime: ', rt
assert rt >= expected_runtime
assert rt < expected_runtime + (expected_runtime * 0.06)
assert valid_func(res)
finally:
model_broadcaster.stop()
示例2: test_timeout_2_times
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_timeout_2_times():
model = make_model()
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
try:
#
# First, we set a short timeout for a command, but a shorter command.
# The command should succeed
#
secs, timeout, expected_runtime = 4, 5, 4
print '\nsleeping for {} secs...'.format(secs)
begin = time.time()
res = model_broadcaster.cmd('sleep', {'secs': secs}, timeout=timeout)
end = time.time()
rt = end - begin
assert rt >= expected_runtime
assert rt < expected_runtime + (expected_runtime * 0.06)
assert is_valid(res)
#
# Next, run a command with no timeout specified. The timeout should
# have reverted back to the default, and the command should succeed.
#
secs, expected_runtime = 9, 9
print '\nsleeping for {} secs...'.format(secs)
begin = time.time()
res = model_broadcaster.cmd('sleep', {'secs': secs})
end = time.time()
rt = end - begin
assert rt >= expected_runtime
assert rt < expected_runtime + (expected_runtime * 0.06)
assert is_valid(res)
finally:
model_broadcaster.stop()
示例3: test_init
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_init():
model = make_model()
with pytest.raises(TypeError):
# no uncertainty arguments
ModelBroadcaster(model)
with pytest.raises(TypeError):
# no spill amount uncertainties
ModelBroadcaster(model,
('down', 'normal', 'up'))
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
try:
assert hasattr(model_broadcaster, 'id')
finally:
model_broadcaster.stop()
示例4: test_uncertainty_array_size
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_uncertainty_array_size():
model = make_model()
model_broadcaster = ModelBroadcaster(model,
('down',),
('down',))
try:
assert len(model_broadcaster.tasks) == 1
finally:
model_broadcaster.stop()
model_broadcaster = ModelBroadcaster(model,
('down', 'up'),
('down', 'up'))
try:
assert len(model_broadcaster.tasks) == 4
finally:
model_broadcaster.stop()
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
try:
assert len(model_broadcaster.tasks) == 9
finally:
model_broadcaster.stop()
示例5: test_uncertainty_array_indexing
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_uncertainty_array_indexing():
model = make_model()
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
try:
res = model_broadcaster.cmd('get_wind_timeseries', {},
('down', 'down'))
assert np.allclose([r[0] for r in res], 17.449237)
res = model_broadcaster.cmd('get_spill_amounts', {}, ('down', 'down'))
assert np.isclose(res[0], 333.33333)
res = model_broadcaster.cmd('get_wind_timeseries', {}, ('up', 'up'))
assert np.allclose([r[0] for r in res], 20.166224)
res = model_broadcaster.cmd('get_spill_amounts', {}, ('up', 'up'))
assert np.isclose(res[0], 1666.66666)
finally:
model_broadcaster.stop()
示例6: test_weathering_output_only
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
def test_weathering_output_only():
model = make_model(geojson_output=True)
model_broadcaster = ModelBroadcaster(model,
('down', 'normal', 'up'),
('down', 'normal', 'up'))
print '\nOutputter results:'
res = model_broadcaster.cmd('get_outputters', {})
assert not [o for r in res for o in r
if not isinstance(o, WeatheringOutput)]
print '\nStep results:'
res = model_broadcaster.cmd('step', {})
assert len(res) == 9
# added a 'valid' flag to output
assert [r.keys() for r in res
if len(r.keys()) == 2
and 'WeatheringOutput' in r]
model_broadcaster.stop()
示例7: the
# 需要導入模塊: from gnome.multi_model_broadcast import ModelBroadcaster [as 別名]
# 或者: from gnome.multi_model_broadcast.ModelBroadcaster import stop [as 別名]
print '\nGetting wind timeseries for all models:'
pp.pprint(model_broadcaster.cmd('get_wind_timeseries', {}))
print '\nGetting spill amounts for all models:'
pp.pprint(model_broadcaster.cmd('get_spill_amounts', {}))
print '\nGetting time & spill values for just the (down, down) model:'
pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
('down', 'down')),
model_broadcaster.cmd('get_spill_amounts', {},
('down', 'down')),
))
print '\nGetting time & spill values for just the (normal, normal) model:'
pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
('normal', 'normal')),
model_broadcaster.cmd('get_spill_amounts', {},
('normal', 'normal')),
))
print '\nGetting time & spill values for just the (up, up) model:'
pp.pprint((model_broadcaster.cmd('get_wind_timeseries', {},
('up', 'up')),
model_broadcaster.cmd('get_spill_amounts', {},
('up', 'up')),
))
model_broadcaster.stop()
print 'main(): stopped broadcaster.'