def test_convex_hull_invalid_min_separation(): x = [0.0, 10.0, 10.0, 5.0, 0.0, 0.0] y = [0.0, 0.0, 10.0, 11.0, 10.0, 0.0] with pytest.raises(ValueError) as e: convex_hull(x, y, min_separation=-1) assert ( e.value.args[0] == "'min_separation' must be non-negative or None.")
def test_convex_hull_adjacent(): x = [0.0, 10.0, 10.0, 5.001, 5.0, 0.0, 0.0] y = [0.0, 0.0, 10.0, 11.000001, 11.0, 10.0, 0.0] xc, yc = convex_hull(x, y, min_separation=None) assert np.allclose([x, y], [xc, yc], rtol=0, atol=1e-14) xc, yc = convex_hull(x, y, min_separation=1e-2) x.pop(3) y.pop(3) assert np.allclose([x, y], [xc, yc], rtol=0, atol=1e-14)
def test_wcsrefcat_convex_hull(mock_fits_wcs): ref = RefCatalog(None) ref._calc_cat_convex_hull() # catalog is None assert convex_hull([], []) == ([], []) assert all( isinstance(x, np.ndarray) and x.size == 0 for x in convex_hull(np.array([]), np.array([]))) assert convex_hull([123], [456]) == ([123], [456]) x = [0, 0, 10, 10] y = [0, 10, 10, 0] xc, yc = convex_hull(x + [10, 3, 6, 7], y + [0, 5, 1, 8]) assert set(xc) == set(x) and set(yc) == set(y) xc, yc = convex_hull(np.array(x + [3, 6, 7]), np.array(y + [5, 1, 8])) assert set(xc) == set(x) and set(yc) == set(y) xc, yc = convex_hull(x + [3, 6, 7], y + [5, 1, 8], lambda x, y: (x, y)) assert set(xc) == set(x) and set(yc) == set(y) xc, yc = convex_hull(np.array(x + [3, 6, 7]), np.array(y + [5, 1, 8]), lambda x, y: (x, y)) assert set(xc) == set(x) and set(yc) == set(y)