Closed
Description
Bug report
Bug summary
The Path.intersects_path function sometimes returns True when it should return False. I've noticed this only when some vertices in the path deviate slightly from round numbers (as sometimes arises from floating point imprecision).
Code for reproduction
from matplotlib.path import Path
path_0 = Path([
[1, -1],
[0, -1],
[0, -2],
[1, -2],
])
path_1 = Path([
[1, 2],
[0, 2],
[0, 1],
[0.999999999999, 1],
])
print(Path.intersects_path(path_0, path_1))
Actual outcome
True
Expected outcome
False
Note that the two paths are completely separated by a large margin along the y axis, so do not intersect.
Additional observations:
- Choosing different y values for the paths or translating the entire configuration by choosing different x values does not change the result.
- Reducing the precision of the last vertex of
path_1
(e.g. making it 1 or 0.9999) changes the result to the expectedFalse
.
Matplotlib version
- Operating system: OS X 10.15.1
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)
): 3.4.2 (bug exists with 3.1.0 as well) - Matplotlib backend (
print(matplotlib.get_backend())
): MacOSX - Python version: 3.7.10
Matplotlib installed using pip in a conda virtual environment (conda activate mpl_bug \ pip install matplotlib
) with no other dependencies installed.