def test_frechet_densify_ndarray(): actual = pygeos.frechet_distance(pygeos.linestrings([[0, 0], [100, 0]]), pygeos.linestrings([[0, 0], [50, 50], [100, 0]]), densify=[0.1, 0.2, 1]) expected = np.array([50, 50.99019514, 70.7106781186548]) np.testing.assert_array_almost_equal(actual, expected)
def test_frechet_distance_densify_empty(): actual = pygeos.frechet_distance(line_string, empty, densify=0.2) assert np.isnan(actual)
def test_frechet_densify_invalid_values(densify): with pytest.raises(pygeos.GEOSException, match="Fraction is not in range"): pygeos.frechet_distance(line_string, line_string, densify=densify)
def test_frechet_densify_nan(): actual = pygeos.frechet_distance(line_string, line_string, densify=np.nan) assert np.isnan(actual)
def test_frechet_distance_nan_for_invalid_geometry_inputs(geom1, geom2): actual = pygeos.frechet_distance(geom1, geom2) assert np.isnan(actual)
def test_frechet_distance_densify(geom1, geom2, densify, expected): actual = pygeos.frechet_distance(geom1, geom2, densify=densify) assert actual == pytest.approx(expected, abs=1e-12)