fix: accept integer capsize in errorbar (#2020)#2024
Merged
Conversation
matplotlib's idiomatic errorbar(..., capsize=4) failed to compile because
capsize was real-only, so the integer literal matched no specific procedure
of the errorbar/add_errorbar generics ("no specific subroutine for the
generic errorbar"). Users read this as "errorbar does not support caps".
Add integer-capsize overloads for errorbar and add_errorbar (RGB and string
color forms) as thin shims that forward to the real-capsize specifics. The
integer capsize argument is required (not optional), so each integer variant
stays distinguishable from its real-capsize counterpart and from the
no-capsize call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2020.
Problem
matplotlib's idiomatic
errorbar(..., capsize=4)(integer) failed tocompile in fortplot:
capsizewas declaredreal(wp)only, so an integer literal matched nospecific procedure of the
errorbar/add_errorbargenerics. The reporterread this as "errorbar does not support caps". (Caps render correctly when
capsizeis passed as a real, e.g.capsize=4.0_wp.)Fix
Add integer-
capsizeoverloads forerrorbarandadd_errorbar(both theRGB-triple and string color forms) as thin shims that convert to real and
forward to the existing specifics. The integer
capsizeargument isrequired (not optional) in each new variant, which keeps it distinguishable
from its real-capsize counterpart and from the no-capsize call, so generic
resolution stays unambiguous.
Verification
Build (serial to avoid the unrelated fpm parallel-build SIGABRT):
Failing before the fix:
Passing after the fix:
The new test (
test/plot_types/errorbar/test_errorbar_capsize_integer.f90)asserts
capsize=4compiles and stores the same cap length (4.0) ascapsize=4.0_wp, read back viafigure_t%get_plots().Existing errorbar tests pass unchanged:
test_errorbar_defaults,test_errorbar_ascii_rendering,test_errorbar_pdf_rendering,test_errorbar_legend_entry,test_errorbar_barsabove_warning,test_stateful_api_fast. Rendering gate (make verify-artifacts) passes.A manual render with
capsize=4shows the horizontal caps drawn at theerror-bar ends.