示例#1
0
def test_move_reference_hex(random_xy, n_rows, n_cols, shape, orientation):
    mg = HexModelGrid(
        n_rows,
        n_cols,
        dx=2.0,
        xy_of_lower_left=random_xy,
        orientation=orientation,
        shape=shape,
    )

    assert mg.xy_of_lower_left == random_xy
    assert mg.x_of_node.min() == random_xy[0]
    assert mg.y_of_node.min() == random_xy[1]

    mg.xy_of_lower_left = (30.0, 45.0)
    assert mg._xy_of_lower_left == (30.0, 45.0)
    assert mg.x_of_node.min() == approx(30.0)
    assert mg.y_of_node.min() == approx(45.0)
示例#2
0
def test_move_reference_hex(random_xy, n_rows, n_cols, node_layout,
                            orientation):
    grid = HexModelGrid(
        (n_rows, n_cols),
        spacing=2.0,
        xy_of_lower_left=random_xy,
        orientation=orientation,
        node_layout=node_layout,
    )

    assert grid.xy_of_lower_left == approx(random_xy)
    assert grid.x_of_node.min() == approx(random_xy[0])
    assert grid.y_of_node.min() == approx(random_xy[1])

    x, y = grid.x_of_node.copy(), grid.y_of_node.copy()

    grid.xy_of_lower_left = (30.0, 45.0)
    assert grid.xy_of_lower_left == (30.0, 45.0)

    assert grid.x_of_node - x == approx(30.0 - random_xy[0])
    assert grid.y_of_node - y == approx(45.0 - random_xy[1])