Example #1
0
def test_line_cx_selection(gp_line, rect):
    x0, y0, x1, y1 = rect
    for xslice in get_slices(x0, x1):
        for yslice in get_slices(y0, y1):
            expected = LineArray.from_geopandas(gp_line.cx[xslice, yslice])
            result = LineArray.from_geopandas(gp_line).cx[xslice, yslice]
            assert all(expected == result)
def data_for_grouping():
    """Data for factorization, grouping, and unique tests.
    Expected to be like [B, B, NA, NA, A, A, B, C]
    Where A < B < C and NA is missing
    """
    return LineArray([[1, 0], [1, 0], None, None, [0, 0], [0, 0], [1, 0],
                      [2, 0]])
def data():
    """Length-100 array for this type.
        * data[0] and data[1] should both be non missing
        * data[0] and data[1] should not gbe equal
        """
    return LineArray([[0, 1], [1, 2, 3, 4], None, [-1, -2], []] * 20,
                     dtype='float64')
Example #4
0
def test_ring_array():
    lines = LineArray([
        unit_square_cw,
        large_square_ccw,
    ])

    np.testing.assert_equal(lines.length, [4.0, 12.0])
    np.testing.assert_equal(lines.area, [0.0, 0.0])
    assert lines.total_bounds == (0.0, 0.0, 3.0, 3.0)
Example #5
0
def test_lines_array():
    lines = LineArray([
        unit_square_cw, large_square_ccw,
        np.concatenate([large_square_ccw, [np.nan, np.nan], unit_square_cw])
    ])

    np.testing.assert_equal(lines.length, [4.0, 12.0, 16.0])
    np.testing.assert_equal(lines.area, [0.0, 0.0, 0.0])
    assert lines.total_bounds == (0.0, 0.0, 3.0, 3.0)
Example #6
0
def test_line_intersects_rect(gp_line, rect):
    sg_rect = sg.box(*rect)

    expected = gp_line.intersects(sg_rect)
    lines = LineArray.from_geopandas(gp_line)

    # Test LineArray.intersects_rect
    result = lines.intersects_bounds(rect)
    np.testing.assert_equal(result, expected)

    # Test LineArray.intersects_rect with inds
    inds = np.flipud(np.arange(0, len(lines)))
    result = lines.intersects_bounds(rect, inds)
    np.testing.assert_equal(result, np.flipud(expected))

    # Test Line.intersects_rect
    result = np.array([line.intersects_bounds(rect) for line in lines])
    np.testing.assert_equal(result, expected)
def data_missing_for_sorting():
    """Length-3 array with a known sort order.
    This should be three items [B, NA, A] with
    A < B and NA missing.
    """
    return LineArray([[1, 0], None, [0, 0]])
def data_for_sorting():
    """Length-3 array with a known sort order.
    This should be three items [B, C, A] with
    A < B < C
    """
    return LineArray([[1, 0], [2, 0], [0, 0]])
def data_missing():
    """Length-2 array with [NA, Valid]"""
    return LineArray([None, [-1, 0, 1, 2]], dtype='int64')
def test_equality():
    a = LineArray([[0, 1], [1, 2, 3, 4], None, [-1, -2], []], dtype='float64')
    assert all(a == a)
    assert all(a[1:-1] == a[[1, 2, 3]])
    assert not any(a[1:-1] == a[[2, 3, 1]])