Skip to content

Commit

Permalink
Rework warn_on_unsupported (#4081)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg authored Jan 28, 2022
1 parent 824dbe9 commit 2896c5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,8 @@ end
const _already_warned = Dict{Symbol,Set{Symbol}}()
const _to_warn = Set{Symbol}()

should_warn_on_unsupported(::AbstractBackend) = _plot_defaults[:warn_on_unsupported]

function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
empty!(_to_warn)
bend = backend_name(pkg)
Expand All @@ -1605,7 +1607,7 @@ function warn_on_unsupported_args(pkg::AbstractBackend, plotattributes)
end

if !isempty(_to_warn) &&
get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported])
get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
for k in sort(collect(_to_warn))
push!(already_warned, k)
@warn(
Expand All @@ -1621,7 +1623,7 @@ end
# _markershape_supported(pkg::AbstractBackend, shapes::AVec) = all([_markershape_supported(pkg, shape) for shape in shapes])

function warn_on_unsupported(pkg::AbstractBackend, plotattributes)
if !get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported])
if !get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
return
end
if !is_seriestype_supported(pkg, plotattributes[:seriestype])
Expand All @@ -1642,7 +1644,7 @@ function warn_on_unsupported(pkg::AbstractBackend, plotattributes)
end

function warn_on_unsupported_scales(pkg::AbstractBackend, plotattributes::AKW)
if !get(plotattributes, :warn_on_unsupported, _plot_defaults[:warn_on_unsupported])
if !get(plotattributes, :warn_on_unsupported, should_warn_on_unsupported(pkg))
return
end
for k in (:xscale, :yscale, :zscale, :scale)
Expand Down
2 changes: 2 additions & 0 deletions src/backends/unicodeplots.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# https://github.com/JuliaPlots/UnicodePlots.jl

should_warn_on_unsupported(::UnicodePlotsBackend) = false

# ------------------------------------------------------------------------------------------
const _canvas_map = (
braille = UnicodePlots.BrailleCanvas,
Expand Down

0 comments on commit 2896c5a

Please sign in to comment.