Skip to content

Conversation

ianthomas23
Copy link
Member

Candidate fix for failed geometry tests to see if CI is happy with it.

Before this PR, I was experiencing failed geometry intersection tests such as when running

pytest spatialpandas/tests/geometry/algorithms/test_intersection.py::test_segment_intersects_point

This tests if a 2D point lies on a straight line segment or not. It tests the line one way, then the other, then compares the result with that obtained from shapely. For some small values, an example being a point that is 2e-17 from one of the end points of the line segment, the test fails.

The failure is not surprising. Our point on line test is not geometrically robust (https://en.wikipedia.org/wiki/Robust_geometric_computation) so it is not surprising that it cannot cope with some small floating point differences. We could make it geometrically robust by always performing the floating-point tests with the points sorted, but then we can't compare with shapely as evidently that is not geometrically robust either. Plus we'd have to improve all the other geometric tests that are somewhat harder than this, and accept a performance penalty.

So this PR avoids the problem by not running tests that our code is not designed to cope with. We are using hypothesis to manage these tests and allowing it to pick any floating point values in the range -1000 to 1000, and being the clever library that it is, eventually it finds the failure modes and concentrates on them. So here I am limiting the floating-point precision to 15 decimal places, which cures the problem for me locally but cannot be guaranteed to always work.

There are longer term issues of whether we need robust geometric tests and/or if comparison with shapely is a good idea or not.

@ianthomas23
Copy link
Member Author

The remaining CI failures are all pyarrow related.

@ianthomas23 ianthomas23 force-pushed the remove_failing_geometry_tests branch from 5268614 to dbaa4ac Compare June 30, 2022 10:48
@ianthomas23
Copy link
Member Author

Rebased on top of other fixes.

@ianthomas23
Copy link
Member Author

I am merging this as it removes some of the CI failures.

@ianthomas23 ianthomas23 merged commit 91968d9 into holoviz:master Jul 25, 2022
@ianthomas23 ianthomas23 deleted the remove_failing_geometry_tests branch July 25, 2022 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant