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


Python Model.reset方法代码示例

本文整理汇总了Python中gnome.model.Model.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Model.reset方法的具体用法?Python Model.reset怎么用?Python Model.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnome.model.Model的用法示例。


在下文中一共展示了Model.reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple_run_with_map

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import reset [as 别名]
def test_simple_run_with_map():
    '''
    pretty much all this tests is that the model will run
    '''

    start_time = datetime(2012, 9, 15, 12, 0)

    model = Model()

    model.map = gnome.map.MapFromBNA(testmap, refloat_halflife=6)  # hours
    a_mover = SimpleMover(velocity=(1., 2., 0.))

    model.movers += a_mover
    assert len(model.movers) == 1

    spill = point_line_release_spill(num_elements=10,
                                     start_position=(0., 0., 0.),
                                     release_time=start_time)

    model.spills += spill
    assert len(model.spills) == 1
    model.start_time = spill.release.release_time

    # test iterator
    for step in model:
        print 'just ran time step: %s' % step
        assert step['step_num'] == model.current_time_step

    # reset and run again
    model.reset()

    # test iterator is repeatable
    for step in model:
        print 'just ran time step: %s' % step
        assert step['step_num'] == model.current_time_step
开发者ID:JamesMakela-NOAA,项目名称:PyGnome,代码行数:37,代码来源:test_model.py

示例2: test_simple_run_with_map

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import reset [as 别名]
def test_simple_run_with_map():
    """
    pretty much all this tests is that the model will run
    """

    start_time = datetime(2012, 9, 15, 12, 0)

    model = Model()

    model.map = gnome.map.MapFromBNA(testmap, refloat_halflife=6)  # hours
    a_mover = SimpleMover(velocity=(1., 2., 0.))

    model.movers += a_mover
    assert len(model.movers) == 1

    spill = PointLineSource(num_elements=10,
            start_position=(0., 0., 0.), release_time=start_time)

    model.spills += spill

    # model.add_spill(spill)

    assert len(model.spills) == 1
    model.start_time = spill.release_time

    # test iterator:

    for step in model:
        print 'just ran time step: %s' % step

    # reset and run again:

    model.reset()

    # test iterator:

    for step in model:
        print 'just ran time step: %s' % step

    assert True
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:42,代码来源:test_model.py


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