From 8e17a182f91f4590c5b90b92e9b3e5f62e70e882 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Sep 2021 15:42:31 +0200 Subject: [PATCH] Format .jl files [skip ci] (#3846) Co-authored-by: t-bltg --- src/backends/pgfplotsx.jl | 7 +++++-- src/backends/plotly.jl | 7 +++++-- src/backends/pyplot.jl | 25 ++++++++++++++++--------- src/backends/unicodeplots.jl | 11 +++++++++-- src/colorbars.jl | 10 +++++++--- src/precompile_includer.jl | 7 +++---- src/utils.jl | 6 ++---- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 32a75c6d..e3b2abb5 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -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]...)], "\n ", ) - elseif typeof(opt[:connections]) <: AbstractVector{NTuple{3, Int}} + elseif typeof(opt[:connections]) <: AbstractVector{NTuple{3,Int}} # 1-based indexing 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 ", ) else diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 872363d9..5269ab14 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -691,9 +691,12 @@ function plotly_series(plt::Plot, series::Series) plotattributes_out[:i] = i plotattributes_out[:j] = j plotattributes_out[:k] = k - elseif typeof(series[:connections]) <: AbstractVector{NTuple{3, Int}} + elseif typeof(series[:connections]) <: AbstractVector{NTuple{3,Int}} # 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[:j] = j plotattributes_out[:k] = k diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 5f484d41..fb23ece4 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -702,29 +702,37 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) polygons = if series[:connections] isa AbstractVector{<:AbstractVector{Int}} # Combination of any polygon types 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) broadcast(inds -> broadcast(i -> [x[i], y[i], z[i]], inds), series[:connections]) elseif series[:connections] isa NTuple{3,<:AbstractVector{Int}} # Only triangles - connections have to be 0-based (indexing) - ci, cj, ck = series[:connections] + ci, cj, ck = series[:connections] if !(length(ci) == length(cj) == length(ck)) throw( - ArgumentError("Argument connections must consist of equally sized arrays."), + ArgumentError( + "Argument connections must consist of equally sized arrays.", + ), ) 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 throw( - ArgumentError("Unsupported `:connections` type $(typeof(series[:connections])) for seriestype=$st"), + ArgumentError( + "Unsupported `:connections` type $(typeof(series[:connections])) for seriestype=$st", + ), ) end - col = mplot3d.art3d.Poly3DCollection(polygons, - linewidths = py_thickness_scale(plt, series[:linewidth]), + col = mplot3d.art3d.Poly3DCollection( + polygons, + linewidths = py_thickness_scale(plt, series[:linewidth]), edgecolor = py_color(get_linecolor(series)), facecolor = py_color(series[:fillcolor]), alpha = get_fillalpha(series), - zorder = series[:series_plotindex] + zorder = series[:series_plotindex], ) handle = ax."add_collection3d"(col) # 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) end - if st == :image xmin, xmax = ignorenan_extrema(series[:x]) ymin, ymax = ignorenan_extrema(series[:y]) diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index c1608579..a7697c10 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -122,7 +122,7 @@ function addUnicodeSeries!( func = UnicodePlots.lineplot! elseif st == :scatter || series[:markershape] != :none func = UnicodePlots.scatterplot! - series_kw = (; marker=series[:markershape]) + series_kw = (; marker = series[:markershape]) else error("Series type $st not supported by UnicodePlots") end @@ -132,7 +132,14 @@ function addUnicodeSeries!( for (n, segment) in enumerate(series_segments(series, st; check = true)) i, rng = segment.attr_index, segment.range 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 for (xi, yi, str, fnt) in EachAnn(series[:series_annotations], x, y) diff --git a/src/colorbars.jl b/src/colorbars.jl index 80726af7..f0cb7c15 100644 --- a/src/colorbars.jl +++ b/src/colorbars.jl @@ -5,7 +5,7 @@ process_clims(s::Union{Symbol,Nothing,Missing}) = ignorenan_extrema # don't specialize on ::Function otherwise python functions won't work 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 for series in series_list(sp) 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) 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] get_clims(sp, op) 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 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 z_colored_series = (:contour, :contour3d, :heatmap, :histogram2d, :surface, :hexbin) for vals in ( diff --git a/src/precompile_includer.jl b/src/precompile_includer.jl index c5df391f..2a19fe91 100644 --- a/src/precompile_includer.jl +++ b/src/precompile_includer.jl @@ -7,10 +7,9 @@ ismultiversion = false @static if !should_precompile # nothing elseif !ismultios && !ismultiversion - @static if isfile(joinpath( - @__DIR__, - "../deps/SnoopCompile/precompile/precompile_Plots.jl", - )) + @static if isfile( + joinpath(@__DIR__, "../deps/SnoopCompile/precompile/precompile_Plots.jl"), + ) include("../deps/SnoopCompile/precompile/precompile_Plots.jl") _precompile_() end diff --git a/src/utils.jl b/src/utils.jl index 83aa022a..5f6d3c59 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1184,9 +1184,7 @@ _document_argument(S::AbstractString) = function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array}) ci, cj, ck = cns if !(length(ci) == length(cj) == length(ck)) - throw( - ArgumentError("Argument connections must consist of equally sized arrays."), - ) + throw(ArgumentError("Argument connections must consist of equally sized arrays.")) end X = zeros(eltype(x), 4length(ci)) Y = zeros(eltype(y), 4length(cj)) @@ -1211,7 +1209,7 @@ function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array}) end return X, Y, Z 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)) Y = zeros(eltype(y), 4length(cns)) Z = zeros(eltype(z), 4length(cns))