Skip to content

Commit 72a229c

Browse files
authored
Fixes after JETLS warnings (#1967)
* Fixes after JETLS warnings * Comment unintended include * Try reset the GMT_SERVER * Correct sever name * Last try
1 parent 109a98d commit 72a229c

20 files changed

Lines changed: 59 additions & 50 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
#- '1.7' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
2929
- '~1.10.0-0'
3030
#- '~1.11.0-0'
31-
- '~1.12.0-0'
31+
#- '~1.12.0-0'
3232
#- '~1.13.0-0'
3333
- 'nightly'
3434
os:

ci/config-gmt-unix.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set (DCW_ROOT "$ENV{COASTLINEDIR}/dcw")
1111
1212
set (GMT_USE_THREADS TRUE)
1313
set (GMT_ENABLE_OPENMP TRUE)
14+
set (GMT_DATA_SERVER https://www.star.nesdis.noaa.gov/data/socd3/lsa/gmtdata/)
1415
1516
# recommended even for release build
1617
set (CMAKE_C_FLAGS "-Wall -Wdeclaration-after-statement ${CMAKE_C_FLAGS}")

src/GMT.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ using .Laszip
407407
grd2cpt(Glix)
408408
grd2xyz(Glix)
409409
viz(Glix, show=false)
410+
viz(I, show=false)
410411
histogram(randn(100), T=0.1, center=true, Z=:counts)
411412
histogram(I)
412413
grdlandmask(R="-10/4/37/45", res=:c, inc=0.1)

src/PrettyTables.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ function _print_table_with_text_back_end(
698698

699699
# Get size information from the processed table.
700700
num_rows, num_columns = _data_size(ptable)
701-
num_header_rows, ~ = _header_size(ptable)
701+
num_header_rows, _ = _header_size(ptable)
702702

703703
# == Input Variables Verification and Initial Setup ====================================
704704

@@ -2526,7 +2526,7 @@ function _print_custom_text_cell!(display::Display, cell_data::CustomTextCell, c
25262526
_p!(display, " ", false, 1)
25272527

25282528
# Compute the new string given the display size.
2529-
str, suffix, ~ = _fit_string_in_display(display, cell_processed_str, false, cell_printable_textwidth)
2529+
str, suffix, _ = _fit_string_in_display(display, cell_processed_str, false, cell_printable_textwidth)
25302530

25312531
new_lstr = textwidth(str)
25322532

src/custom_symb_funs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function flower_minho(; name::String="flower_minho", width=14, fmt="", format=""
1717
figsize=(width,0), # Fig size. Second arg = 0 means compute the height keeping aspect ratio
1818
frame=:none, # Do not plot the frame
1919
p=opt_p)
20-
plot!(x, y, fill=(pattern=TESTSDIR * "tiling2.jpg", dpi=dpi), name = name * _fmt)
20+
plot!(x, y, fill=(pattern=tests("tiling2.jpg"), dpi=dpi), name = name * _fmt)
2121
(show == 1) && showfig()
2222
end
2323

src/gdal_utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ Write a MxNxP `cube` object to disk as a multilayered file.
965965
function gdalwrite(fname::AbstractString, data, optsP=String[]; opts=String[], kw...)
966966
(fname == "") && error("Output file name is missing.")
967967
(isempty(optsP) && !isempty(opts)) && (optsP = opts) # Accept either Positional or KW argument
968-
isa(optsP, AbstractString) && (optsP = gdal_opts2vec(optsP)) # Guarantied to return a Vector{String}
968+
isa(optsP, AbstractString) && (optsP = Gdal.gdal_opts2vec(optsP)) # Guarantied to return a Vector{String}
969969
ds = Gdal.get_gdaldataset(data, optsP)[1]
970970
if (Gdal.GDALGetRasterCount(ds.ptr) >= 1)
971971
gdaltranslate(ds, optsP; dest=fname, kw...)

src/gmt_main.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ function get_PS(API::Ptr{Nothing}, object::Ptr{Nothing})::GMTps
614614
end
615615

616616
# ---------------------------------------------------------------------------------------------------
617-
function get_dataset(API::Ptr{Nothing}, object::Ptr{Nothing})::GDtype
617+
function get_dataset(object::Ptr{Nothing})::GDtype
618618
# Given a GMT DATASET D, build an array of segment structure and assign values.
619619
# Each segment will have 6 items:
620620
# header: Text string with the segment header (could be empty)
@@ -799,7 +799,7 @@ function GMTJL_Get_Object(API::Ptr{Nothing}, X::GMT_RESOURCE)
799799
elseif (X.family == GMT_IS_CUBE) # A GMT cube; make it the pos'th output item
800800
ptr = get_grid(API, X.object, true)
801801
elseif (X.family == GMT_IS_DATASET) # A GMT table; make it a matrix and the pos'th output item
802-
ptr = get_dataset(API, X.object)
802+
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
804804
ptr = get_palette(API, X.object)
805805
elseif (X.family == GMT_IS_IMAGE) # A GMT Image; make it the pos'th output item

src/gmtreadwrite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function gmtread(fname::String; kwargs...)
9191
end
9292
function gmtread(fname::String, d::Dict{Symbol, Any})
9393

94-
endswith(fname, ".xlsx") && return read_xls(_fname; kwargs...) # Excel extension
94+
endswith(fname, ".xlsx") && return read_xls(fname; d...) # Excel extension
9595

9696
#fname::String = _fname # Because args signatures seam to worth shit in body.
9797
#d = init_module(false, kwargs...)[1] # Also checks if the user wants ONLY the HELP mode

src/gmtspatial.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ gmtspatial(arg1, arg2; kw...) = gmtspatial_helper("", arg1, arg2; kw...)
5454

5555
# ---------------------------------------------------------------------------------------------------
5656
function gmtspatial_helper(cmd0::String, arg1, arg2; kw...)
57-
(cmd0 == "" && arg1 === nothing && arg2 === nothing && length(kwargs) == 0) && return gmt("gmtspatial")
57+
(cmd0 == "" && arg1 === nothing && arg2 === nothing && length(kw) == 0) && return gmt("gmtspatial")
5858
d = init_module(false, kw...)[1] # Also checks if the user wants ONLY the HELP mode
5959
isa(arg1, Matrix) && (arg1 = mat2ds(arg1))
6060
invokelatest(_gmtspatial_helper, cmd0, arg1, arg2, d)

src/imshow.jl

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ julia> viz(G, zsize=6, facades=(TESTSDIR*"assets/cenora_base.jpg", TESTSDIR*"bun
3434
See also: [`grdimage`](@ref), [`grdview`](@ref)
3535
"""
3636
function imshow(arg1, x::AbstractVector{Float64}=Float64[], y::AbstractVector{Float64}=Float64[]; kw...)
37+
_imshow(arg1, x, y, KW(kw))
38+
end
39+
function _imshow(@nospecialize(arg1), x::AbstractVector{Float64}, y::AbstractVector{Float64}, d::Dict{Symbol,Any})
3740
# Take a 2D array of floats and turn it into a GMTgrid or if input is a string assume it's a file name
3841
# In this later case try to figure if it's a grid or an image and act accordingly.
3942

40-
see = ((val = find_in_kwargs(kw, [:show])[2]) === nothing) ? true : (val != 0) # No explicit 'show' keyword means show=true
43+
see = (!haskey(d, :show)) ? true : (d[:show] != 0) # No explicit 'show' keyword means show=true
4144

42-
function isplot3(kw)
45+
function _isplot3(d::Dict)
4346
_call_plot3 = false
44-
opt_p = find_in_kwargs(kw, [:p :view :perspective])[1]
47+
opt_p = find_in_dict(d, [:p :view :perspective], false)[1]
4548
(isa(opt_p, String) && contains(opt_p, '/')) && (_call_plot3 = true)
4649
((isa(opt_p, Tuple) || isa(opt_p, VMr)) && length(opt_p) > 1) && (_call_plot3 = true)
4750
return _call_plot3
@@ -60,10 +63,9 @@ function imshow(arg1, x::AbstractVector{Float64}=Float64[], y::AbstractVector{Fl
6063
ext = lowercase(ext)
6164
(ext == ".jpg" || ext == ".tif" || ext == ".tiff" || ext == ".png" || ext == ".bmp" || ext == ".gif") && (is_image = true)
6265
!is_image && (Gg = arg1)
63-
#snif_GI_set_CTRLlimits(arg1) # Set CTRL.limits to be eventually used by J=:guess
6466
end
6567
elseif (isa(arg1, Array{UInt8}) || isa(arg1, Array{UInt16,3}) || isa(arg1, Array{Bool}) || isa(arg1, BitMatrix))
66-
Gi = isa(arg1, BitMatrix) ? mat2img(collect(arg1); kw...) : mat2img(arg1; kw...)
68+
Gi = isa(arg1, BitMatrix) ? mat2img(collect(arg1); d...) : mat2img(arg1; d...)
6769
call_img = true
6870
elseif (isa(arg1, GDtype) || isa(arg1, GMTfv) || isa(arg1, Vector{GMTfv}) || (isa(arg1, AbstractVecOrMat{<:Real}) && size(arg1,2) <= 4) || (isa(arg1, Gdal.AbstractDataset) || isa(arg1, Gdal.AbstractGeometry)))
6971
(isa(arg1, Gdal.AbstractDataset) || isa(arg1, Gdal.AbstractGeometry)) && (arg1 = gd2gmt(arg1))
@@ -82,13 +84,15 @@ function imshow(arg1, x::AbstractVector{Float64}=Float64[], y::AbstractVector{Fl
8284
call_plot3 = ((isa(arg1, GMTdataset) && arg1.geom == wkbPolygonZM) ||
8385
(isa(arg1, Vector{<:GMTdataset}) && arg1[1].geom == wkbPolygonZM) ||
8486
isFV3D) ? true : false # Should evolve into a fun that detects the several plot3d cases.
85-
!call_plot3 && (call_plot3 = isplot3(kw))
86-
return (call_plot3) ? plot3d(arg1; show=see, kw...) : plot(arg1; show=see, kw...)
87+
!call_plot3 && (call_plot3 = _isplot3(d))
88+
d[:show] = see
89+
return (call_plot3) ? plot3d(arg1; d...) : plot(arg1; d...)
8790
elseif (isa(arg1, GMTcpt))
88-
return (find_in_kwargs(kw, [:D :pos :position])[1] === nothing) ?
89-
psscale(arg1; show=true, D="x0/0+w7+h", kw...) : psscale(arg1; show=true, kw...)
91+
return (find_in_dict(d, [:D :pos :position], false)[1] === nothing) ?
92+
psscale(arg1; show=true, D="x0/0+w7+h", d...) : psscale(arg1; show=true, d...)
9093
elseif (isdataframe(arg1) || isODE(arg1))
91-
return isplot3(kw) ? plot3(arg1; show=see, kw...) : plot(arg1; show=see, kw...)
94+
d[:show] = see
95+
return _isplot3(d) ? plot3(arg1; d...) : plot(arg1; d...)
9296
else
9397
Gg = mat2grid(arg1, x, y, reg=1) # For displaying, pixel registration is more appropriate
9498
call_grd = true
@@ -98,17 +102,18 @@ function imshow(arg1, x::AbstractVector{Float64}=Float64[], y::AbstractVector{Fl
98102
call_grd && snif_GI_set_CTRLlimits(Gg)
99103

100104
if (is_image)
101-
grdimage(arg1; show=see, kw...)
105+
grdimage(arg1; show=see, d...)
102106
else
103-
if (isa(Gg, String)) # Guess also if call grdview or grdimage
104-
if (get(kw, :JZ, 0) != 0 || get(kw, :Jz, 0) != 0 || get(kw, :zscale, 0) != 0 || get(kw, :zsize, 0) != 0)
105-
(get(kw, :Q, "") == "" && get(kw, :surf, "") == "" && get(kw, :surftype, "") == "") && (kw = (kw..., Q="s"))
106-
grdview(arg1; show=see, kw...) # String when fname is @xxxx
107+
if (isa(Gg, String)) # Guess also if call grdview or grdimage
108+
d[:show] = see
109+
if (get(d, :JZ, 0) != 0 || get(d, :Jz, 0) != 0 || get(d, :zscale, 0) != 0 || get(d, :zsize, 0) != 0)
110+
(get(d, :Q, "") == "" && get(d, :surf, "") == "" && get(d, :surftype, "") == "") && (d[:Q] = "s")
111+
grdview(arg1; d...) # String when fname is @xxxx
107112
else
108-
grdimage(arg1; show=see, kw...)
113+
grdimage(arg1; d...)
109114
end
110115
else
111-
imshow(call_img ? Gi : Gg; kw...) # Call the specialized method
116+
_imshow_GI(call_img ? Gi : Gg, d) # Call the specialized method directly
112117
end
113118
end
114119
end
@@ -122,12 +127,14 @@ end
122127
# - `T, no_interp, tiles`: -T option for grdview
123128
# - `facades, cubeplot`: Call cubeplot.
124129
function imshow(arg1::GItype; kw...)
125-
# Here the default is to show, but if a 'show' was used let it rule
126-
d = KW(kw)
130+
_imshow_GI(arg1, KW(kw))
131+
end
132+
function _imshow_GI(arg1::GItype, d::Dict{Symbol,Any})
127133
see::Bool = (!haskey(d, :show)) ? true : (d[:show] != 0) # No explicit 'show' keyword means show=true
128134

129-
if (isa(arg1, GMTimage) && (size(arg1, 3) <= 3 || arg1.layout[4] == 'A')) # Rest of the work is done in grdiamge
130-
return grdimage("", arg1; show=see, kw...)
135+
if (isa(arg1, GMTimage) && (size(arg1, 3) <= 3 || arg1.layout[4] == 'A')) # Rest of the work is done in grdimage
136+
d[:show] = see
137+
return grdimage_helper(wrapGrids("", arg1), nothing, nothing, true, false, d)
131138
end
132139

133140
if ((cont_opts = find_in_dict(d, [:contour])[1]) !== nothing)
@@ -138,7 +145,7 @@ function imshow(arg1::GItype; kw...)
138145
have_tilles::Bool = ((til = find_in_dict(d, [:T :no_interp :tiles])[1]) !== nothing)
139146
(!have_tilles && opt_p != "" && !contains(opt_p, '/')) && (flat = true) # If only 'azimuth' and no 'elev'
140147
flat::Bool = (find_in_dict(d, [:flat])[1] !== nothing) # If true, force the use of grdimage
141-
docube = is_in_kwargs(kw, [:facades :cubeplot])
148+
docube = is_in_dict(d, [:facades :cubeplot]) !== nothing
142149
(flat && docube) && (flat = false)
143150

144151
if (!docube && (flat || (opt_p == "" && !have_tilles)))
@@ -232,15 +239,16 @@ end
232239

233240
# Simple method to show CPTs. (May grow)
234241
# Ex: imshow(C, xlabel="Bla", ylabel="Blu"), or imshow(:gray)
235-
imshow(arg1::Symbol; horizontal::Bool=false, kw...) = imshow(makecpt(arg1); horizontal=horizontal, kw...)
242+
imshow(arg1::Symbol; horizontal::Bool=false, kw...) = imshow(makecpt(arg1); horizontal=horizontal, kw...)
236243
function imshow(arg1::GMTcpt; horizontal::Bool=false, kw...)
237-
see::Bool = (!haskey(kw, :show)) ? true : kw[:show] # No explicit 'show' keyword means show=true
238-
horizontal ? psscale(arg1; D="x8c/1c+w12c/0.5c+jTC+h", show=see, kw...) : psscale(arg1; J="X15/0", D="x8c/1c+w12c/0.5c+jBC", show=see, kw...)
244+
d = KW(kw)
245+
see::Bool = (!haskey(d, :show)) ? true : (d[:show] != 0)
246+
horizontal ? psscale(arg1; D="x8c/1c+w12c/0.5c+jTC+h", show=see, d...) : psscale(arg1; J="X15/0", D="x8c/1c+w12c/0.5c+jBC", show=see, d...)
239247
end
240248

241249
function imshow(arg1::Gdal.AbstractDataset; kw...)
242250
(Gdal.GDALGetRasterCount(arg1.ptr) == 0) && return plot(gd2gmt(arg1), show=1)
243-
imshow(gd2gmt(arg1); kw...)
251+
_imshow_GI(gd2gmt(arg1), KW(kw))
244252
end
245253

246254
imshow(x::AbstractVector{Float64}, y::AbstractVector{Float64}, f::Function; kw...) = imshow(mat2grid(f, x, y); kw...)

0 commit comments

Comments
 (0)