本文整理汇总了Python中gnome.model.Model.setup_model_run方法的典型用法代码示例。如果您正苦于以下问题:Python Model.setup_model_run方法的具体用法?Python Model.setup_model_run怎么用?Python Model.setup_model_run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.model.Model
的用法示例。
在下文中一共展示了Model.setup_model_run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_weatherer_sort
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import setup_model_run [as 别名]
def test_weatherer_sort():
'''
Sample model with weatherers - only tests sorting of weathereres. The
Model will likely not run
'''
model = Model()
skimmer = Skimmer(100, 'kg', efficiency=0.3,
active_start=datetime(2014, 1, 1, 0, 0),
active_stop=datetime(2014, 1, 1, 0, 3))
burn = Burn(100, 1, active_start=datetime(2014, 1, 1, 0, 0))
c_disp = ChemicalDispersion(.3,
active_start=datetime(2014, 1, 1, 0, 0),
active_stop=datetime(2014, 1, 1, 0, 3),
efficiency=0.2)
weatherers = [Emulsification(),
Evaporation(Water(),
constant_wind(1, 0)),
burn,
c_disp,
skimmer]
#exp_order = [weatherers[ix] for ix in (2, 4, 3, 1, 0)]
exp_order = [weatherers[ix] for ix in (4, 2, 3, 1, 0)]
model.environment += [Water(), constant_wind(5, 0), Waves()]
model.weatherers += weatherers
# WeatheringData and FayGravityViscous automatically get added to
# weatherers. Only do assertion on weatherers contained in list above
assert model.weatherers.values()[:len(exp_order)] != exp_order
model.setup_model_run()
assert model.weatherers.values()[:len(exp_order)] == exp_order
# check second time around order is kept
model.rewind()
assert model.weatherers.values()[:len(exp_order)] == exp_order
# Burn, ChemicalDispersion are at same sorting level so appending
# another Burn to the end of the list will sort it to be just after
# ChemicalDispersion so index 2
burn = Burn(50, 1, active_start=datetime(2014, 1, 1, 0, 0))
exp_order.insert(2, burn)
model.weatherers += exp_order[2] # add this and check sorting still works
assert model.weatherers.values()[:len(exp_order)] != exp_order
model.setup_model_run()
assert model.weatherers.values()[:len(exp_order)] == exp_order