Skip to content

Commit 37cc4d8

Browse files
authored
Third batch of changes after JETLS advices. (#1969)
1 parent 2a907a5 commit 37cc4d8

12 files changed

Lines changed: 27 additions & 21 deletions

File tree

src/PrettyTables.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function crop_width_to_fit_string_in_field(str::AbstractString, field_width::Int
4444

4545
# If the user is asking for the continuation char, we must crop the string to account
4646
# for the continuation char.
47-
cont_str = ""
4847

4948
if add_continuation_char
5049
cont_str_width = textwidth(continuation_char)
@@ -2579,6 +2578,8 @@ function _text_process_data_cell(ptable::ProcessedTable, cell_data::Any, cell_st
25792578
lstr = textwidth(cell_str)
25802579

25812580
if cell_data isa CustomTextCell
2581+
@warn "CustomTextCell is not supported in the current version of Custom PrettyTables.jl."
2582+
#=
25822583
# To align a custom text cell, we need to compute the alignment and cropping data
25832584
# and apply it using the API functions.
25842585
padding = padding_for_string_alignment(cell_str, column_width, alignment; fill = true, printable_string_width = lstr)
@@ -2600,6 +2601,7 @@ function _text_process_data_cell(ptable::ProcessedTable, cell_data::Any, cell_st
26002601
end
26012602
26022603
cell_str = get_printable_cell_line(cell_data, l)::String
2604+
=#
26032605
else
26042606
# Align and crop the string to be printed.
26052607
cell_str = align_string(cell_str, column_width, alignment; fill = true, printable_string_width = lstr)
@@ -3069,9 +3071,12 @@ end
30693071

30703072
function _text_parse_cell(@nospecialize(io::IOContext), cell::CustomTextCell; kwargs...)
30713073
# Call the API function to reset all the fields in the custom text cell.
3074+
@warn "CustomTextCell is not supported in the current version of Custom PrettyTables.jl."
3075+
#=
30723076
reset!(cell)
30733077
cell_vstr = parse_cell_text(cell; kwargs...)
30743078
return cell_vstr
3079+
=#
30753080
end
30763081

30773082
_text_parse_cell(@nospecialize(io::IOContext), cell::Missing; kwargs...) = ["missing"]
@@ -3100,7 +3105,7 @@ function _text_render_cell(::Val{:print}, @nospecialize(io::IOContext), str::Abs
31003105
# to the list of characters to be escaped.
31013106
output_str = Vector{String}(undef, length(vstr))
31023107

3103-
@inbounds for i in 1:length(vstr)
3108+
@inbounds for i in 1:numel(vstr)
31043109
s = vstr[i]
31053110
output_str[i] = sprint(escape_string, s, "", sizehint = lastindex(s))
31063111
end
@@ -3128,7 +3133,7 @@ function _text_render_cell(::Val{:show}, @nospecialize(io::IOContext), v::Abstra
31283133
vstr = sprint.(show, aux; context = context)
31293134

31303135
if !isstring
3131-
for i in 1:length(vstr)
3136+
for i in 1:numel(vstr)
31323137
aux_i = first(vstr[i], length(vstr[i]) - 1)
31333138
vstr[i] = last(aux_i, length(aux_i) - 1)
31343139
end

src/gdal/gdal.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ OGR_G_Contains(a1, a2) = acare(ccall((:OGR_G_Contains, libgdal), Cint, (pVoid, p
515515
OGR_G_ConvexHull(a1) = acare(ccall((:OGR_G_ConvexHull, libgdal), pVoid, (pVoid,), a1))
516516
OGR_G_ConcaveHull(a1, a2, a3) = acare(ccall((:OGR_G_ConcaveHull, libgdal), pVoid, (pVoid, Cdouble, Bool), a1, a2, a3))
517517
OGR_G_CreateGeometry(a1) = acare(ccall((:OGR_G_CreateGeometry, libgdal), pVoid, (UInt32,), a1))
518+
OGR_G_CreateFromWkt(a1, a2, a3) = acare(ccall((:OGR_G_CreateFromWkt, libgdal), Cint, (Ptr{Cstring}, pVoid, pVoid), a1, a2, a3))
518519
OGR_G_Crosses(a1, a2) = acare(ccall((:OGR_G_Crosses, libgdal), Cint, (pVoid, pVoid), a1, a2))
519520
OGR_G_DelaunayTriangulation(hThis, tol, edges) = acare(ccall((:OGR_G_DelaunayTriangulation, libgdal), pVoid, (pVoid, Cdouble, Cint), hThis, tol, edges))
520521
OGR_G_Simplify(hThis, tolerance) = acare(ccall((:OGR_G_Simplify, libgdal), pVoid, (pVoid, Cdouble), hThis, tolerance))

src/gmt_main.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ end
360360
=#
361361

362362
# ---------------------------------------------------------------------------------------------------
363-
function get_grid(API::Ptr{Nothing}, object, cube::Bool)::GMTgrid
363+
function get_grid(object, cube::Bool)::GMTgrid
364364
# Given an incoming GMT grid G, build a Julia type and assign the output components.
365365
# Note: Incoming GMT grid has standard padding while Julia grid has none.
366366

@@ -795,9 +795,9 @@ function GMTJL_Get_Object(API::Ptr{Nothing}, X::GMT_RESOURCE)
795795
error("GMT: Error reading virtual file $name from GMT")
796796

797797
if (X.family == GMT_IS_GRID) # A GMT grid; make it the pos'th output item
798-
ptr = get_grid(API, X.object, false)
798+
ptr = get_grid(X.object, false)
799799
elseif (X.family == GMT_IS_CUBE) # A GMT cube; make it the pos'th output item
800-
ptr = get_grid(API, X.object, true)
800+
ptr = get_grid(X.object, true)
801801
elseif (X.family == GMT_IS_DATASET) # A GMT table; make it a matrix and the pos'th output item
802802
ptr = get_dataset(X.object)
803803
elseif (X.family == GMT_IS_PALETTE) # A GMT CPT; make it a colormap and the pos'th output item

src/gmtconnect.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ To see the documentation, type: ``@? gmtconnect``
55
"""
66
function gmtconnect(cmd0::String="", arg1=nothing, arg2=nothing; kw...)
77
d = init_module(false, kw...)[1]
8-
gmtconnect(cmd0, arg1, d)
8+
gmtconnect(cmd0, arg1, arg2, d)
99
end
10-
function gmtconnect(cmd0::String, arg1, d::Dict{Symbol, Any})
10+
function gmtconnect(cmd0::String, arg1, arg2, d::Dict{Symbol, Any})
1111

1212
cmd, = parse_common_opts(d, "", [:V_params :b :d :e :f :g :h :i :o :yx])
1313
cmd = parse_these_opts(cmd, d, [[:C :closed], [:D :dump], [:L :links :linkfile], [:Q :list :listfile], [:T :tolerance]])
1414

15-
common_grd(d, cmd0, cmd, "gmtconnect ", arg1) # Finish build cmd and run it
15+
common_grd(d, cmd0, cmd, "gmtconnect ", arg1, arg2) # Finish build cmd and run it
1616
end
1717

1818
# ---------------------------------------------------------------------------------------------------

src/grd_operations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ function Base.:permutedims(G1::GMTgrid, inds; nodata=nothing)
452452
end
453453
mat = permutedims(G1.z, inds)
454454
# 3,2,1 3,1,2, 2,1,3 2,3,1 1,3,2
455-
if (inds == [3,2,1]) x, v, x_unit = v, x, G1.z_unit
456-
elseif (inds == [3,1,2]) x, y, v, x_unit = v, x, y, G1.z_unit
455+
if (inds == [3,2,1]) x, v = v, x
456+
elseif (inds == [3,1,2]) x, y, v = v, x, y
457457
end
458458
_nodata = G1.nodata
459459
if (nodata !== nothing && eltype(G1) <: AbstractFloat && !isnan(nodata))

src/imgmorph/bwdist.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function bwdist(img::AbstractArray{Bool, N}; weights=nothing, nthreads=Threads.n
66
distance_transform(ft, weights)
77
end
88
function bwdist_idx(img::AbstractArray{Bool, N}; weights=nothing, nthreads=Threads.nthreads()) where {N}
9-
ft = feature_transform(img; weights=weights, nthreads=nthreads)
9+
feature_transform(img; weights=weights, nthreads=nthreads)
1010
end
1111

1212
bwdist(mat::AbstractArray{T, N}; weights=nothing, nthreads=Threads.nthreads()) where {T,N} =

src/libgmt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ function GMT_Get_Enum(API::Ptr{Cvoid}, enum_name::String)
359359
end
360360

361361
function GMT_Get_Version()
362-
ver = ccall((:GMT_Get_Version, libgmt), Cfloat, (Ptr{Cvoid}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}), C_NULL, C_NULL, C_NULL, C_NULL)
362+
ccall((:GMT_Get_Version, libgmt), Cfloat, (Ptr{Cvoid}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}), C_NULL, C_NULL, C_NULL, C_NULL)
363363
end
364364
function GMT_Get_Version(major, minor, patch)
365-
ver = ccall((:GMT_Get_Version, libgmt), Cfloat, (Ptr{Cvoid}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}), C_NULL, major, minor, patch)
365+
ccall((:GMT_Get_Version, libgmt), Cfloat, (Ptr{Cvoid}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}), C_NULL, major, minor, patch)
366366
end
367367

368368
function GMT_Get_Ctrl(API::Ptr{Cvoid})

src/pshistogram.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function histogram_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol,A
246246
vlines!([limit_L], pen="0.5p,blue,dashed", decorated=(quoted = true, n_labels = 1, const_label = "$limit_L", font = 9, pen = (0.5, :red)), R=opt_R[4:end], Vd=Vd_)
247247
out2 = vlines!([limit_R], pen="0.5p,blue,dashed", decorated=(quoted = true, n_labels = 1, const_label = "$limit_R", font = 9, pen = (0.5, :red)), R=opt_R[4:end], fmt=fmt_, savefig=savefig_, show=show_, Vd=Vd_)
248248
end
249-
out = (out1 !== nothing && out2 !== nothing) ? [out1;out2] : ((out1 !== nothing) ? out1 : out2)
249+
(out1 !== nothing && out2 !== nothing) ? [out1;out2] : ((out1 !== nothing) ? out1 : out2)
250250

251251
end
252252

src/pslegend.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ function mk_legend(; kwargs...)
137137
for n = 1:numel(ky)
138138
code = isa(kwargs[n], NamedTuple) ? kwargs[n] : NamedTuple([ky[n]] .=> [kwargs[n]])
139139
kw_str = lowercase(string(ky[n]))
140-
k = keys(code)
141140
if (kw_str == "H" || startswith(kw_str, "header")) # code = (header=txt, font=?) H 24p,Times-Roman My Map Legend
142141
d = nt2dict(code)
143142
f::String = ((val = find_in_dict(d, [:font])[1]) === nothing) ? "-" : font(val)

src/statplots.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ end
658658

659659
# ----------------------------------------------------------------------------------------------------------
660660
# Build violin polygon as a matrix. Uses loops instead of broadcast/vcat/hcat to reduce IR bloat.
661-
function _violin_polygon(d::Vector{Float64}, xd, x::Float64, split::Int, isVert::Bool)
661+
function _violin_polygon(d::AbstractVector{Float64}, xd, x::Float64, split::Int, isVert::Bool)
662662
n = length(d)
663663
if split == 0 # Both sides
664664
m = 2n + 1
@@ -754,7 +754,9 @@ function helper1_violin(data::Union{Vector{Vector{T}}, AbstractMatrix{T}}, x::Ve
754754
xd, d = Base.invokelatest(view,Dv[k].data,:,1), Base.invokelatest(view,Dv[k].data,:,2)
755755
maxd = maximum(d)
756756
scale = 1/2N_grp * 0.75 * groupwidth
757-
d = [d[i] * scale / maxd for i in eachindex(d)]
757+
for i in eachindex(d)
758+
d[i] * scale / maxd
759+
end
758760
(k == 2 && split != 0 && swing) && (split = (split == 1) ? 2 : 1) # Not realy sure why we have to do this.
759761
Dv[k].data = _violin_polygon(d, xd, _x[k] + off_in_grp, split, isVert)
760762

0 commit comments

Comments
 (0)