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


Python Model.setup_model_run方法代码示例

本文整理汇总了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
开发者ID:liuy0813,项目名称:PyGnome,代码行数:53,代码来源:test_model.py


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