Example #1
0
def test_from_file():
    sensor_grid = SensorGrid.from_file('./tests/assets/test_points.pts')
    assert sensor_grid.identifier == 'test_points'
    assert sensor_grid[0].pos == (0, 0, 0)
    assert sensor_grid[0].dir == (0, 0, 1)
    assert len(sensor_grid) == 3
    assert sensor_grid[1].to_radiance() == '0.2 0.3 0.4 0.5 0.6 0.7'
    assert sensor_grid[2].to_radiance() == '-10.0 -5.0 0.0 -50.0 -60.0 -70.0'
Example #2
0
def test_split_single_grid():
    """Test splitting a sensor grid."""
    sensor_grid = SensorGrid.from_file(
        './tests/assets/grid/sensor_grid_split.pts')
    folder = './tests/assets/temp'
    info = sensor_grid.to_files(folder, 1, 'single_grid')
    assert len(info) == 1
    assert info[0]['count'] == sensor_grid.count
Example #3
0
def test_split_grid():
    """Test splitting a sensor grid."""
    sensor_grid = SensorGrid.from_file(
        './tests/assets/grid/sensor_grid_split.pts')
    folder = './tests/assets/temp'
    info = sensor_grid.to_files(folder, 6, 'test_sensor_grid')
    assert len(info) == 6
    for i in range(6 - 1):
        assert info[i]['count'] == 4

    assert info[-1]['count'] == 1
Example #4
0
def test_split_grid_single():
    input_grid = './tests/assets/grid/sensor_grid_single.pts'
    output_folder = './tests/assets/temp'
    runner = CliRunner()
    result = runner.invoke(split_grid, [input_grid, '100', '--folder', output_folder])
    assert result.exit_code == 0
    # check the file is created and named correctly
    pts_file = os.path.join(output_folder, 'sensor_grid_single_0000.pts')
    assert os.path.isfile(pts_file)
    grid = SensorGrid.from_file(pts_file)
    assert grid.count == 21
Example #5
0
def test_merge_grid():
    base_name = 'sensor_grid_merge'
    input_folder = './tests/assets/grid'
    output_folder = './tests/assets/temp'
    runner = CliRunner()
    result = runner.invoke(
        merge_grid, [input_folder, base_name, '--folder', output_folder])
    assert result.exit_code == 0
    # check the file is created
    pts_file = os.path.join(output_folder, base_name + '.pts')
    assert os.path.isfile(pts_file)
    grid = SensorGrid.from_file(pts_file)
    assert grid.count == 21
Example #6
0
def test_split_grid():
    input_grid = './tests/assets/grid/sensor_grid_split.pts'
    output_folder = './tests/assets/temp'
    runner = CliRunner()
    result = runner.invoke(split_grid, [input_grid, '5', '--folder', output_folder])
    assert result.exit_code == 0
    # check the file is created
    for count in range(4):
        pts_file = os.path.join(output_folder, 'sensor_grid_split_%04d.pts' % count)
        assert os.path.isfile(pts_file)
        grid = SensorGrid.from_file(pts_file)
        if count != 3:
            assert grid.count == 5
        else:
            assert grid.count == 6