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


Python Simulation.create_empty_data_matrix方法代码示例

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


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

示例1: test_matrix_updates_from_cars

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_matrix_updates_from_cars():
    with mock.patch('random.random', return_value=.50):
        sim = Simulation(4)
        sim.create_cars(4)
        sim.create_empty_data_matrix()
        sim.give_cars_starting_places()
        sim.advance_cars_and_record()
        sim.decide_speed_and_record()
        assert sim.cars[0].speed == 2
开发者ID:jdhiggins,项目名称:traffic-simulation,代码行数:11,代码来源:test_simulation.py

示例2: test_decide_speed_sets_new_speed_for_cars

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_decide_speed_sets_new_speed_for_cars():
    with mock.patch("random.random", return_value=.5):
        sim = Simulation(4)
        sim.create_cars(4)
        sim.create_empty_data_matrix()
        sim.give_cars_starting_places()
        sim.advance_cars_and_record()
        sim.decide_speed_and_record()
        assert sim.cars[0].speed ==2
        assert sim.turn_count ==1
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:12,代码来源:test_simulation.py

示例3: test_advance_cars_and_record_adds_speed_to_car_location_over_1000

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_advance_cars_and_record_adds_speed_to_car_location_over_1000():
    sim = Simulation(4)
    sim.create_cars(4)
    sim.create_empty_data_matrix()
    sim.give_cars_starting_places()
    sim.advance_cars_and_record()
    sim.turn_count +=1
    sim.data_matrix[1][1] = [10, 10, 10, 10]
    sim.advance_cars_and_record()
    assert np.array_equal(sim.data_matrix[0][2], [15, 345, 675, 5])
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:12,代码来源:test_simulation.py

示例4: test_advance_cars_and_record_adds_speed_to_car_location

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_advance_cars_and_record_adds_speed_to_car_location():
    sim = Simulation(4)
    sim.create_cars(4)
    sim.create_empty_data_matrix()
    sim.give_cars_starting_places()
    sim.advance_cars_and_record()
    assert np.array_equal(sim.data_matrix[0][1], sim.data_matrix[0][0])
    sim.turn_count +=1
    sim.data_matrix[1][1] = [2, 2, 2, 2]
    sim.advance_cars_and_record()
    assert np.array_equal(sim.data_matrix[0][2], [7, 337, 667, 997])
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:13,代码来源:test_simulation.py

示例5: test_cars_get_starting_places

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_cars_get_starting_places():
    sim = Simulation(4)
    sim.create_cars(4)
    sim.create_empty_data_matrix()
    start_setup = sim.give_cars_starting_places()
    assert sim.cars[0].location == 5
    assert sim.cars[1].location == 335
    assert np.array_equal(start_setup, [5, 335, 665, 995])
    assert sim.data_matrix.shape == (2, 121, 4)
    assert sim.data_matrix[0].shape == (121, 4)
    assert sim.data_matrix[0][0].shape == (4,)
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:13,代码来源:test_simulation.py

示例6: test_matrix_updates_from_cars

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_matrix_updates_from_cars():
      with mock.patch("random.random", return_value=.5):
        sim = Simulation(4)
        sim.create_cars(4)
        sim.create_empty_data_matrix()
        sim.give_cars_starting_places()
        sim.advance_cars_and_record()
        sim.decide_speed_and_record()
        sim.turn_count +=1
        sim.advance_cars_and_record()
        sim.decide_speed_and_record()
        assert sim.data_matrix[1][sim.turn_count][0] == sim.cars[0].speed
        assert sim.cars[3].speed == 4
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:15,代码来源:test_simulation.py

示例7: test_create_speed_matrix

# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import create_empty_data_matrix [as 别名]
def test_create_speed_matrix():
    sim = Simulation(4)
    sim.create_cars(4)
    sim.create_empty_data_matrix()
    assert (sim.data_matrix.size) == 968
    assert (sim.data_matrix.shape) == (2, 121, 4)
开发者ID:tshealy,项目名称:traffic-simulation,代码行数:8,代码来源:test_simulation.py


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