Format .jl files [skip ci] (#3846)

Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2021-09-26 15:42:31 +02:00 committed by GitHub
parent 032c5d1638
commit 8e17a182f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 26 deletions

View File

@ -518,10 +518,13 @@ function pgfx_add_series!(::Val{:mesh3d}, axis, series_opt, series, series_func,
[string(i, " ", j, " ", k, "\\\\") for (i, j, k) in zip(opt[:connections]...)], [string(i, " ", j, " ", k, "\\\\") for (i, j, k) in zip(opt[:connections]...)],
"\n ", "\n ",
) )
elseif typeof(opt[:connections]) <: AbstractVector{NTuple{3, Int}} elseif typeof(opt[:connections]) <: AbstractVector{NTuple{3,Int}}
# 1-based indexing # 1-based indexing
ptable = join( ptable = join(
[string(i-1, " ", j-1, " ", k-1, "\\\\") for (i, j, k) in opt[:connections]], [
string(i - 1, " ", j - 1, " ", k - 1, "\\\\") for
(i, j, k) in opt[:connections]
],
"\n ", "\n ",
) )
else else

View File

@ -691,9 +691,12 @@ function plotly_series(plt::Plot, series::Series)
plotattributes_out[:i] = i plotattributes_out[:i] = i
plotattributes_out[:j] = j plotattributes_out[:j] = j
plotattributes_out[:k] = k plotattributes_out[:k] = k
elseif typeof(series[:connections]) <: AbstractVector{NTuple{3, Int}} elseif typeof(series[:connections]) <: AbstractVector{NTuple{3,Int}}
# 1-based indexing # 1-based indexing
i, j, k = broadcast(i -> [ inds[i]-1 for inds in series[:connections]], (1, 2, 3)) i, j, k = broadcast(
i -> [inds[i] - 1 for inds in series[:connections]],
(1, 2, 3),
)
plotattributes_out[:i] = i plotattributes_out[:i] = i
plotattributes_out[:j] = j plotattributes_out[:j] = j
plotattributes_out[:k] = k plotattributes_out[:k] = k

View File

@ -702,7 +702,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
polygons = if series[:connections] isa AbstractVector{<:AbstractVector{Int}} polygons = if series[:connections] isa AbstractVector{<:AbstractVector{Int}}
# Combination of any polygon types # Combination of any polygon types
broadcast(inds -> broadcast(i -> [x[i], y[i], z[i]], inds), series[:connections]) broadcast(inds -> broadcast(i -> [x[i], y[i], z[i]], inds), series[:connections])
elseif series[:connections] isa AbstractVector{NTuple{N, Int}} where N elseif series[:connections] isa AbstractVector{NTuple{N,Int}} where {N}
# Only N-gons - connections have to be 1-based (indexing) # Only N-gons - connections have to be 1-based (indexing)
broadcast(inds -> broadcast(i -> [x[i], y[i], z[i]], inds), series[:connections]) broadcast(inds -> broadcast(i -> [x[i], y[i], z[i]], inds), series[:connections])
elseif series[:connections] isa NTuple{3,<:AbstractVector{Int}} elseif series[:connections] isa NTuple{3,<:AbstractVector{Int}}
@ -710,21 +710,29 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
ci, cj, ck = series[:connections] ci, cj, ck = series[:connections]
if !(length(ci) == length(cj) == length(ck)) if !(length(ci) == length(cj) == length(ck))
throw( throw(
ArgumentError("Argument connections must consist of equally sized arrays."), ArgumentError(
"Argument connections must consist of equally sized arrays.",
),
) )
end end
broadcast(j -> broadcast(i -> [x[i], y[i], z[i]], [ci[j]+1, cj[j]+1, ck[j]+1]), eachindex(ci)) broadcast(
j -> broadcast(i -> [x[i], y[i], z[i]], [ci[j] + 1, cj[j] + 1, ck[j] + 1]),
eachindex(ci),
)
else else
throw( throw(
ArgumentError("Unsupported `:connections` type $(typeof(series[:connections])) for seriestype=$st"), ArgumentError(
"Unsupported `:connections` type $(typeof(series[:connections])) for seriestype=$st",
),
) )
end end
col = mplot3d.art3d.Poly3DCollection(polygons, col = mplot3d.art3d.Poly3DCollection(
polygons,
linewidths = py_thickness_scale(plt, series[:linewidth]), linewidths = py_thickness_scale(plt, series[:linewidth]),
edgecolor = py_color(get_linecolor(series)), edgecolor = py_color(get_linecolor(series)),
facecolor = py_color(series[:fillcolor]), facecolor = py_color(series[:fillcolor]),
alpha = get_fillalpha(series), alpha = get_fillalpha(series),
zorder = series[:series_plotindex] zorder = series[:series_plotindex],
) )
handle = ax."add_collection3d"(col) handle = ax."add_collection3d"(col)
# Fix for handle: https://stackoverflow.com/questions/54994600/pyplot-legend-poly3dcollection-object-has-no-attribute-edgecolors2d # Fix for handle: https://stackoverflow.com/questions/54994600/pyplot-legend-poly3dcollection-object-has-no-attribute-edgecolors2d
@ -734,7 +742,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
push!(handles, handle) push!(handles, handle)
end end
if st == :image if st == :image
xmin, xmax = ignorenan_extrema(series[:x]) xmin, xmax = ignorenan_extrema(series[:x])
ymin, ymax = ignorenan_extrema(series[:y]) ymin, ymax = ignorenan_extrema(series[:y])

View File

@ -122,7 +122,7 @@ function addUnicodeSeries!(
func = UnicodePlots.lineplot! func = UnicodePlots.lineplot!
elseif st == :scatter || series[:markershape] != :none elseif st == :scatter || series[:markershape] != :none
func = UnicodePlots.scatterplot! func = UnicodePlots.scatterplot!
series_kw = (; marker=series[:markershape]) series_kw = (; marker = series[:markershape])
else else
error("Series type $st not supported by UnicodePlots") error("Series type $st not supported by UnicodePlots")
end end
@ -132,7 +132,14 @@ function addUnicodeSeries!(
for (n, segment) in enumerate(series_segments(series, st; check = true)) for (n, segment) in enumerate(series_segments(series, st; check = true))
i, rng = segment.attr_index, segment.range i, rng = segment.attr_index, segment.range
lc = get_linecolor(series, i) lc = get_linecolor(series, i)
up = func(up, x[rng], y[rng]; color = up_color(lc), name = n == 1 ? label : "", series_kw...) up = func(
up,
x[rng],
y[rng];
color = up_color(lc),
name = n == 1 ? label : "",
series_kw...,
)
end end
for (xi, yi, str, fnt) in EachAnn(series[:series_annotations], x, y) for (xi, yi, str, fnt) in EachAnn(series[:series_annotations], x, y)

View File

@ -5,7 +5,7 @@ process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema
# don't specialize on ::Function otherwise python functions won't work # don't specialize on ::Function otherwise python functions won't work
process_clims(f) = f process_clims(f) = f
function get_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64, Float64} function get_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64,Float64}
zmin, zmax = Inf, -Inf zmin, zmax = Inf, -Inf
for series in series_list(sp) for series in series_list(sp)
if series[:colorbar_entry] if series[:colorbar_entry]
@ -15,7 +15,11 @@ function get_clims(sp::Subplot, op = process_clims(sp[:clims]))::Tuple{Float64,
return zmin <= zmax ? (zmin, zmax) : (NaN, NaN) return zmin <= zmax ? (zmin, zmax) : (NaN, NaN)
end end
function get_clims(sp::Subplot, series::Series, op = process_clims(sp[:clims]))::Tuple{Float64, Float64} function get_clims(
sp::Subplot,
series::Series,
op = process_clims(sp[:clims]),
)::Tuple{Float64,Float64}
zmin, zmax = if series[:colorbar_entry] zmin, zmax = if series[:colorbar_entry]
get_clims(sp, op) get_clims(sp, op)
else else
@ -31,7 +35,7 @@ Finds the limits for the colorbar by taking the "z-values" for the series and pa
which must return the tuple `(zmin, zmax)`. The default op is the extrema of the finite which must return the tuple `(zmin, zmax)`. The default op is the extrema of the finite
values of the input. values of the input.
""" """
function get_clims(series::Series, op = ignorenan_extrema)::Tuple{Float64, Float64} function get_clims(series::Series, op = ignorenan_extrema)::Tuple{Float64,Float64}
zmin, zmax = Inf, -Inf zmin, zmax = Inf, -Inf
z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin) z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin)
for vals in ( for vals in (

View File

@ -7,10 +7,9 @@ ismultiversion = false
@static if !should_precompile @static if !should_precompile
# nothing # nothing
elseif !ismultios && !ismultiversion elseif !ismultios && !ismultiversion
@static if isfile(joinpath( @static if isfile(
@__DIR__, joinpath(@__DIR__, "../deps/SnoopCompile/precompile/precompile_Plots.jl"),
"../deps/SnoopCompile/precompile/precompile_Plots.jl", )
))
include("../deps/SnoopCompile/precompile/precompile_Plots.jl") include("../deps/SnoopCompile/precompile/precompile_Plots.jl")
_precompile_() _precompile_()
end end

View File

@ -1184,9 +1184,7 @@ _document_argument(S::AbstractString) =
function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array}) function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array})
ci, cj, ck = cns ci, cj, ck = cns
if !(length(ci) == length(cj) == length(ck)) if !(length(ci) == length(cj) == length(ck))
throw( throw(ArgumentError("Argument connections must consist of equally sized arrays."))
ArgumentError("Argument connections must consist of equally sized arrays."),
)
end end
X = zeros(eltype(x), 4length(ci)) X = zeros(eltype(x), 4length(ci))
Y = zeros(eltype(y), 4length(cj)) Y = zeros(eltype(y), 4length(cj))
@ -1211,7 +1209,7 @@ function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array})
end end
return X, Y, Z return X, Y, Z
end end
function mesh3d_triangles(x, y, z, cns::AbstractVector{NTuple{3, Int}}) function mesh3d_triangles(x, y, z, cns::AbstractVector{NTuple{3,Int}})
X = zeros(eltype(x), 4length(cns)) X = zeros(eltype(x), 4length(cns))
Y = zeros(eltype(y), 4length(cns)) Y = zeros(eltype(y), 4length(cns))
Z = zeros(eltype(z), 4length(cns)) Z = zeros(eltype(z), 4length(cns))