From 0411a6c1e087f3f888506963331c14cbe92fdfad Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:32:55 +0200 Subject: [PATCH] Fix: Do not use numeric tolerances for axline special cases vertical lines (infinite slope) and two identical points as input need special handling in AxLine. The detection was using numeric tolerances, which lead to false-positive detection in cases that are close to but not exactly those special cases. This PR removes the tolerances. The argument is the same as for the similar case https://github.com/matplotlib/matplotlib/issues/28386#issuecomment-2314629415 Closes #28870. --- lib/matplotlib/lines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index 5a7c83ccbc06..65a4ccb6d950 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -1506,8 +1506,8 @@ def get_transform(self): points_transform.transform([self._xy1, self._xy2]) dx = x2 - x1 dy = y2 - y1 - if np.allclose(x1, x2): - if np.allclose(y1, y2): + if dx == 0: + if dy == 0: raise ValueError( f"Cannot draw a line through two identical points " f"(x={(x1, x2)}, y={(y1, y2)})")
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: