Exemplo n.º 1
0
def test_section_region_mapping_offset_single_region():
    coord_range = {
        "min_x": 0,
        "min_z": 0,
        "max_x": 512,
        "max_z": 512,
    }

    offset_x = 512
    offset_z = 512

    offset = math.coord_offset(offset_x, offset_z)

    min_bound = math.coord_to_region(coord_range['min_x'],
                                     coord_range['min_z'])
    max_bound = math.coord_to_region(coord_range['max_x'],
                                     coord_range['max_z'])

    regions = math.regions_for_range(min_bound[0], min_bound[1], max_bound[0],
                                     max_bound[1])
    mappings = tuple(math.region_mappings(regions, offset))

    print(mappings, sep='\n')

    assert len(mappings) == 4
    assert mappings[0] == ((0, 0), (1, 1)), "head of region mapping not valid"
    assert mappings[3] == ((1, 1), (2, 2)), "tail of region mapping not valid"
Exemplo n.º 2
0
def test_region_12_20_exists_in_list():
    min_x = -10
    min_z = -10
    max_x = 30
    max_z = 30

    region_ranges = math.regions_for_range(min_x, min_z, max_x, max_z)

    assert [12, 20] in region_ranges
Exemplo n.º 3
0
def test_region_permutations_length():
    min_x = 0
    min_z = 0
    max_x = 50
    max_z = 50

    region_ranges = math.regions_for_range(min_x, min_z, max_x, max_z)

    assert len(region_ranges) == 2601
Exemplo n.º 4
0
def test_region_permutations_not_empty():
    min_x = 0
    min_z = 0
    max_x = 5
    max_z = 5

    region_ranges = math.regions_for_range(min_x, min_z, max_x, max_z)

    assert len(region_ranges) != 0
Exemplo n.º 5
0
def test_region_for_invalid_range_z():
    min_x = 0
    min_z = 0
    max_x = 0
    max_z = -200

    min_bound = math.coord_to_region(min_x, min_z)
    max_bound = math.coord_to_region(max_x, max_z)

    with pytest.raises(AssertionError):
        region_ranges = math.regions_for_range(min_bound[0], min_bound[1],
                                               max_bound[0], max_bound[1])
Exemplo n.º 6
0
def test_region_min_max_bounds():
    min_x = -1210
    min_z = -1357
    max_x = 6206
    max_z = 6281

    min_bound = math.coord_to_region(min_x, min_z)
    max_bound = math.coord_to_region(max_x, max_z)

    region_ranges = math.regions_for_range(min_bound[0], min_bound[1],
                                           max_bound[0], max_bound[1])

    assert [-3, -3] in region_ranges, "lower region bound does not exist"
    assert [12, 12] in region_ranges, "max region bound does not exist"
Exemplo n.º 7
0
def test_region_for_coords_0_0_to_neg200_neg200():
    max_x = 0
    max_z = 0
    min_x = -200
    min_z = -200

    min_bound = math.coord_to_region(min_x, min_z)
    max_bound = math.coord_to_region(max_x, max_z)

    region_ranges = math.regions_for_range(min_bound[0], min_bound[1],
                                           max_bound[0], max_bound[1])

    assert [0, 0] in region_ranges, "higher region bound does not exist"
    assert [-1, -1] in region_ranges, "lower region bound does not exist"
    assert len(
        region_ranges) == 4, "small bounds can't be bigger than 1 region"
Exemplo n.º 8
0
def calculate_regions(coord_range, offset_coord, from_path, to_path):
    offset_x = offset_coord[0]
    offset_z = offset_coord[1]
    offset = math.coord_offset(offset_x, offset_z)

    min_bound = math.coord_to_region(coord_range[0], coord_range[1])
    max_bound = math.coord_to_region(coord_range[2], coord_range[3])

    regions = math.regions_for_range(min_bound[0], min_bound[1], max_bound[0],
                                     max_bound[1])
    mappings = tuple(math.region_mappings(regions, offset))
    args = []
    l = numpy.array_split(mappings, 8)
    for region in l:
        args.append({
            'offset': (offset_x, offset_z),
            'from_path': from_path,
            'to_path': to_path,
            'regions': region
        })

    p = Pool(8)
    p.map(pool_output_regions, args)
Exemplo n.º 9
0
def test_b173_to_v115():
    coord_range = {
        "min_x": -1203,
        "min_z": -1342,
        "max_x": 6208,
        "max_z": 6280,
    }

    offset_x = 10000
    offset_z = -13000

    offset = math.coord_offset(offset_x, offset_z)

    min_bound = math.coord_to_region(coord_range['min_x'],
                                     coord_range['min_z'])
    max_bound = math.coord_to_region(coord_range['max_x'],
                                     coord_range['max_z'])

    regions = math.regions_for_range(min_bound[0], min_bound[1], max_bound[0],
                                     max_bound[1])
    mappings = tuple(math.region_mappings(regions, offset))

    assert len(mappings) != 0
Exemplo n.º 10
0
def test_region_12_20_doesnt_exist_in_list():
    coords = {"min_x": -10, "min_z": -10, "max_x": 10, "max_z": 10}

    region_ranges = math.regions_for_range(**coords)

    assert ([12, 20] in region_ranges) == False