Fix FancyArrow rendering for zero-length arrows#30243
Fix FancyArrow rendering for zero-length arrows#30243QuLogic merged 6 commits intomatplotlib:mainfrom
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
| else: | ||
| length = distance + head_length | ||
| if not length: | ||
| if (isinstance(length, np.ndarray) and length.size == 0) or (not length): |
|
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.