-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix FancyArrow rendering for zero-length arrows #30243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ad9c92b
to
070837b
Compare
This PR only affects FancyArrow behavior when length == 0 and adds a test for it. The CI failures in docs/AppVeyor are unrelated and seem to be happening globally. Pre-commit passes locally. |
lib/matplotlib/patches.py
Outdated
@@ -1538,7 +1538,7 @@ def _make_verts(self): | |||
length = distance | |||
else: | |||
length = distance + head_length | |||
if not length: | |||
if (isinstance(length, np.ndarray) and length.size == 0) or (not length): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use np.size
here.
Thank you for the review, @QuLogic! 🙌 |
Thanks @nrnavaneet! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
…3.10.x Backport PR #30243 on branch v3.10.x (Fix FancyArrow rendering for zero-length arrows)
Fixes #30242: Cannot create empty FancyArrow (expired NumPy deprecation).
Summary of changes:
• Addresses a bug where FancyArrow(length=0) caused issues due to expired NumPy behavior.
• Adds an explicit check for zero length to safely initialize self.verts as an empty array.
• Adds a test case test_empty_fancyarrow in test_patches.py to confirm correct behavior for zero-length arrows.
This change ensures that FancyArrow gracefully handles length=0 without triggering errors or deprecated behavior in newer NumPy versions.