def test_xy_to_bbox(): bbox = [0, 0, 1, 5] g = Grid2D(bbox) bbox2 = Grid2D.xy_to_bbox(g.xy) assert np.all(bbox == bbox2) bbox2 = Grid2D.xy_to_bbox(g.xy, buffer=0.2) assert bbox2[0] == -0.2 assert bbox2[3] == 5.2
def test_xy_to_bbox(): bbox = [0, 0, 1, 5] g = Grid2D(bbox) xy = np.array([[0, 0], [0, 1], [1, 0], [1, 1], [0, 5], [1, 5]], dtype=float) bbox2 = Grid2D.xy_to_bbox(xy) assert bbox[0] == bbox2[0] assert bbox[-1] == bbox2[-1] bbox2 = Grid2D.xy_to_bbox(xy, buffer=0.2) assert bbox2[0] == -0.2 assert bbox2[3] == 5.2