Skip to content

Commit 8565ad5

Browse files
authored
Some more kwargs-to-dict and docstrings line removal. (#1926)
1 parent ea9aa0d commit 8565ad5

16 files changed

Lines changed: 62 additions & 108 deletions

src/GMT.jl

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,40 @@ using InteractiveUtils
88
using Leptonica_jll
99

1010
struct CTRLstruct
11-
limits::Vector{Float64}# To store the data limits. First 6 store: data limits. Second 6: plot limits, 13th +r
12-
figsize::Vector{Float64}# To store the current fig size (xsize,ysize[,zsize]). Needed, for example, in hexbin
13-
proj_linear::Vector{Bool}# To know if images sent to GMT need Pad
14-
returnPS::Vector{Bool}# To know if returning the PS to Julia
15-
callable::Vector{Symbol}# Modules that can be called inside other modules
16-
pocket_B::Vector{String}# To temporarily store opt_B grid and fill color to be reworked in psclip
17-
pocket_J::Vector{String}# To temporarily store opt_J and fig size to eventualy flip directions (y + down, etc)
11+
limits::Vector{Float64} # To store the data limits. First 6 store: data limits. Second 6: plot limits, 13th +r
12+
figsize::Vector{Float64} # To store the current fig size (xsize,ysize[,zsize]). Needed, for example, in hexbin
13+
proj_linear::Vector{Bool} # To know if images sent to GMT need Pad
14+
returnPS::Vector{Bool} # To know if returning the PS to Julia
15+
callable::Vector{Symbol} # Modules that can be called inside other modules
16+
pocket_B::Vector{String} # To temporarily store opt_B grid and fill color to be reworked in psclip
17+
pocket_J::Vector{String} # To temporarily store opt_J and fig size to eventualy flip directions (y + down, etc)
1818
# = [opt_J width opt_Jz codes-to-tell-which-axis-to-reverse]
19-
pocket_R::Vector{String}# To temporarily store opt_R
20-
XYlabels::Vector{String}# To temporarily store the x,y col names to let x|y labels know what to plot (if "auto")
21-
IamInPaperMode::Vector{Bool}# A 2 elem vec to know if we are in under-the-hood paper mode. 2nd traces if first call
22-
gmt_mem_bag::Vector{Ptr{Cvoid}}# To temporarily store a GMT owned memory to be freed in gmt()
23-
pocket_d::Vector{Dict{Symbol,Any}}# To pass the Dict of kwargs, after consumption, to other modules.
19+
pocket_R::Vector{String} # To temporarily store opt_R
20+
XYlabels::Vector{String} # To temporarily store the x,y col names to let x|y labels know what to plot (if "auto")
21+
IamInPaperMode::Vector{Bool} # A 2 elem vec to know if we are in under-the-hood paper mode. 2nd traces if first call
22+
gmt_mem_bag::Vector{Ptr{Cvoid}} # To temporarily store a GMT owned memory to be freed in gmt()
23+
pocket_d::Vector{Dict{Symbol,Any}} # To pass the Dict of kwargs, after consumption, to other modules.
2424
end
2525

2626
mutable struct CTRLstruct2
27-
first::Bool# Signal that we are starting a new plot (used to set params)
28-
points::Bool# If maps are using points as coordinates
29-
fname::String# Store the full name of PS being constructed
27+
first::Bool # Signal that we are starting a new plot (used to set params)
28+
points::Bool # If maps are using points as coordinates
29+
fname::String # Store the full name of PS being constructed
3030
end
3131

3232
mutable struct TMPDIRInfo
33-
dir::String# Temporary directory path
34-
username::String# Username (spaces replaced with underscores)
35-
pid_suffix::String# PID suffix for multi-process support
33+
dir::String # Temporary directory path
34+
username::String # Username (spaces replaced with underscores)
35+
pid_suffix::String # PID suffix for multi-process support
3636
end
3737

3838
mutable struct InsetInfo
39-
active::Bool# Whether currently in inset mode
40-
has_J::Bool# Whether -J projection option was provided (GMT bug #7005 workaround)
39+
active::Bool # Whether currently in inset mode
40+
has_J::Bool # Whether -J projection option was provided (GMT bug #7005 workaround)
4141
end
4242

43-
depfile = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")# File with shared lib names
44-
isfile(depfile) && include(depfile)# This loads the shared libs names in the case of NON-JLL, otherwise just return
43+
depfile = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl") # File with shared lib names
44+
isfile(depfile) && include(depfile) # This loads the shared libs names in the case of NON-JLL, otherwise just return
4545

4646
if ((!(@isdefined have_jll) || have_jll == 1) && get(ENV, "SYSTEMWIDE_GMT", "") == "")# That is, the JLL case
4747
using GMT_jll, GDAL_jll, PROJ_jll, Ghostscript_jll
@@ -53,52 +53,52 @@ if ((!(@isdefined have_jll) || have_jll == 1) && get(ENV, "SYSTEMWIDE_GMT", "")
5353
const GMTbin = GMT_jll.gmt()[1]
5454
const isJLL = true
5555
fname = joinpath(GMTuserdir[1], "ghost_jll_path.txt")
56-
!isdir(GMTuserdir[1]) && mkdir(GMTuserdir[1])# When installing on a clean no GMT sys, ~/.gmt doesn't exist
56+
!isdir(GMTuserdir[1]) && mkdir(GMTuserdir[1]) # When installing on a clean no GMT sys, ~/.gmt doesn't exist
5757
open(fname, "w") do f
58-
write(f, GSbin)# Save this to be used by psconvert.c
58+
write(f, GSbin) # Save this to be used by psconvert.c
5959
end
6060
else
6161
const isJLL = false
6262
const GMTver, libgmt, libgdal, libproj, GMTuserdir, GMTbin = _GMTver, _libgmt, _libgdal, _libproj, [userdir], "gmt"
63-
const GMTdevdate = Date(devdate, dateformat"y.m.d")# 'devdate' comes from reading 'deps.jl'
63+
const GMTdevdate = Date(devdate, dateformat"y.m.d") # 'devdate' comes from reading 'deps.jl'
6464
end
6565

6666
const G_API = Ref{Ptr{Cvoid}}(C_NULL)
67-
const PSname = Ref{String}("")# The PS file (filled in __init__) where, in classic mode, all lands.
68-
const TMPDIR_USR = TMPDIRInfo(tempdir(), "", "")# Save the tmp dir and user name (also filled in __init__)
67+
const PSname = Ref{String}("") # The PS file (filled in __init__) where, in classic mode, all lands.
68+
const TMPDIR_USR = TMPDIRInfo(tempdir(), "", "") # Save the tmp dir and user name (also filled in __init__)
6969
const global TESTSDIR = joinpath(dirname(pathof(GMT))[1:end-4], "test", "")# To have easy access to test files
70-
const IMG_MEM_LAYOUT = Ref{String}("")# "TCP" For Images.jl. The default is "TRBa"
71-
const GRD_MEM_LAYOUT = Ref{String}("")# "BRP" is the default for GMT PS images.
72-
const CURRENT_VIEW = Ref{String}("")# To store the current viewpoint (-p)
73-
const MULTI_COL = Ref{Bool}(false)# To allow plottig multiple columns at once.
74-
const IamModern = Ref{Bool}(false)# To know if we are in modern mode
75-
const FirstModern = Ref{Bool}(false)# To know
76-
const DidOneGmtCmd = Ref{Bool}(false)# To know when first gmt() call. Used in first modern mode cmd to not restart what is still fresh
77-
const IamModernBySubplot = Ref{Bool}(false)# To know if set in subpot
78-
const IamSubplot = Ref{Bool}(false)# To know if we are in subplot mode
79-
const IamInset = InsetInfo(false, false)# To know if we are in Inset mode
80-
const usedConfPar = Ref{Bool}(false)# Hacky solution for the session's memory trouble
81-
const ThemeIsOn = Ref{Bool}(false)# To know if we have an active plot theme
82-
const CONVERT_SYNTAX = Ref{Bool}(false)# To only convert to hard core GMT syntax (like Vd=2)
83-
const SHOW_KWARGS = Ref{Bool}(false)# To just print the kwargs of a option call)
84-
const isFranklin = Ref{Bool}(false)# Only set/unset by the Docs building scripts.
85-
const isJupyter = Ref{Bool}(false)# Jupyter and Modern need special treatment (Quarto).
86-
const isPSclosed = Ref{Bool}(false)# Modern mode will close the PS at the end. We need to know that
87-
const noGrdCopy = Ref{Bool}(false)# If true, grids are sent without transpose/copy
88-
const GMTCONF = Ref{Bool}(false)# Flag if gmtset was used and must be 'unused'
89-
const FMT = Ref{String}("png")# The default plot format
90-
const BOX_STR = Ref{String}("")# Used in plotyy to know -R of first call
70+
const IMG_MEM_LAYOUT = Ref{String}("") # "TCP" For Images.jl. The default is "TRBa"
71+
const GRD_MEM_LAYOUT = Ref{String}("") # "BRP" is the default for GMT PS images.
72+
const CURRENT_VIEW = Ref{String}("") # To store the current viewpoint (-p)
73+
const MULTI_COL = Ref{Bool}(false) # To allow plottig multiple columns at once.
74+
const IamModern = Ref{Bool}(false) # To know if we are in modern mode
75+
const FirstModern = Ref{Bool}(false) # To know
76+
const DidOneGmtCmd = Ref{Bool}(false) # To know when first gmt() call. Used in first modern mode cmd to not restart what is still fresh
77+
const IamModernBySubplot = Ref{Bool}(false) # To know if set in subpot
78+
const IamSubplot = Ref{Bool}(false) # To know if we are in subplot mode
79+
const IamInset = InsetInfo(false, false) # To know if we are in Inset mode
80+
const usedConfPar = Ref{Bool}(false) # Hacky solution for the session's memory trouble
81+
const ThemeIsOn = Ref{Bool}(false) # To know if we have an active plot theme
82+
const CONVERT_SYNTAX = Ref{Bool}(false) # To only convert to hard core GMT syntax (like Vd=2)
83+
const SHOW_KWARGS = Ref{Bool}(false) # To just print the kwargs of a option call)
84+
const isFranklin = Ref{Bool}(false) # Only set/unset by the Docs building scripts.
85+
const isJupyter = Ref{Bool}(false) # Jupyter and Modern need special treatment (Quarto).
86+
const isPSclosed = Ref{Bool}(false) # Modern mode will close the PS at the end. We need to know that
87+
const noGrdCopy = Ref{Bool}(false) # If true, grids are sent without transpose/copy
88+
const GMTCONF = Ref{Bool}(false) # Flag if gmtset was used and must be 'unused'
89+
const FMT = Ref{String}("png") # The default plot format
90+
const BOX_STR = Ref{String}("") # Used in plotyy to know -R of first call
9191
const POSTMAN = Ref{Dict{String,String}}(Dict{String,String}()) # To pass messages to functions (start with get_dataset)
92-
const DEF_FIG_SIZE = "15c/10c" # Default fig size for plot like programs. Approx 16/11
93-
const DEF_FIG_AXES_BAK = " -Baf -BWSen" # Default fig axes for plot like programs
94-
const DEF_FIG_AXES3_BAK = " -Baf -Bza" # "" but for 3D views
95-
const DEF_FIG_AXES = Ref{String}(DEF_FIG_AXES_BAK) # This one may be be changed by theme()
96-
const DEF_FIG_AXES3 = Ref{String}(DEF_FIG_AXES3_BAK) # ""
92+
const DEF_FIG_SIZE = "15c/10c" # Default fig size for plot like programs. Approx 16/11
93+
const DEF_FIG_AXES_BAK = " -Baf -BWSen" # Default fig axes for plot like programs
94+
const DEF_FIG_AXES3_BAK = " -Baf -Bza" # "" but for 3D views
95+
const DEF_FIG_AXES = Ref{String}(DEF_FIG_AXES_BAK) # This one may be be changed by theme()
96+
const DEF_FIG_AXES3 = Ref{String}(DEF_FIG_AXES3_BAK)# ""
9797
const FIG_MARGIN = Ref{Int}(1) # Figure margin in points after convertion by 'psconvert'. Accessible 'margin' common option
9898
const global CTRL = CTRLstruct(zeros(13), zeros(6), [true], [false],
9999
[:arrows, :bubblechart, :basemap, :band, :clip, :coast, :colorbar, :grdcontour, :hband, :hlines, :inset, :logo, :lines, :grdvector, :plot, :plot3, :quiver, :scatter, :scatter3, :stairs, :text, :vlines, :vband], ["", "", ""], ["", "", "", " "], ["", ""], ["", ""], [false, true], [C_NULL], [Dict()])
100100
const pocket_call = Ref{Vector{Any}}(Any[nothing, nothing, nothing, nothing, nothing, nothing])# Extracted from CTRL to isolate type instability
101-
const CTRLshapes = CTRLstruct2(true, true, "")# Used in sub-module Drawing
101+
const CTRLshapes = CTRLstruct2(true, true, "") # Used in sub-module Drawing
102102
const prj4WGS84 = "+proj=longlat +datum=WGS84 +units=m +no_defs"# This is used in many places
103103
const global CPTaliases = [:C :color :cmap :colormap :colorscale]
104104
const global VMs = Union{Vector{Symbol},Matrix{Symbol}}

src/gmtinfo.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,6 @@ end
5252
# ---------------------------------------------------------------------------------------------------
5353
function gmtinfo_helper(cmd0::String, arg1, d::Dict{Symbol,Any})::Union{String, GMTdataset}
5454

55-
#=
56-
#cmd, = parse_common_opts(d, "", [:V_params :e :f :i :o :r :w :yx])
57-
cmd = parse_V_params(d, "")
58-
cmd = parse_e(d, cmd)[1]
59-
cmd = parse_f(d, cmd)[1]
60-
cmd = parse_i(d, cmd)[1]
61-
cmd = parse_o(d, cmd)[1]
62-
cmd = parse_r(d, cmd)[1]
63-
cmd = parse_w(d, cmd)[1]
64-
cmd = parse_swap_xy(d, cmd)[1]
65-
(endswith(cmd, "-:")) && (cmd *= "i") # Need to be -:i not -: to not swap output too
66-
cmd = parse_these_opts(cmd, d, [[:A :ranges], [:C :numeric :per_column], [:D :center], [:E :get_record], [:F :counts],
67-
[:L :common_limits], [:S :for_error_bars]])
68-
cmd = add_opt(d, cmd, "I", [:I :inc :increment :spacing],
69-
(exact=("e", nothing, 1), polyg=("b", nothing, 1), surface=("s", nothing, 1), fft=("d", nothing, 1), inc=("", arg2str, 2)); del=false, expand=true)
70-
cmd = add_opt(d, cmd, "T", [:T :nearest_multiple], (dz="", col="+c", column="+c"))
71-
=#
72-
7355
cmd = gmtinfo_helper_helper(d) # Parse only options that do not depend on the (fcking Any) 'arg1'
7456

7557
if (cmd0 != "") cmd = cmd * " " * cmd0

src/grdproject.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Project a geographical gridded data set onto a rectangular grid or do the inverse projection.
55
6-
See full GMT docs at [`grdproject`]($(GMTdoc)grdproject.html)
7-
86
Parameters
97
----------
108

src/plot.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ Example:
14661466
"""
14671467
function hlines(arg1=nothing; first=true, xmin=NaN, xmax=NaN, percent=false, kwargs...)
14681468
# A lines plotting method of plot
1469-
helper_vhlines(arg1, false, first, xmin, xmax, percent, kwargs...)
1469+
helper_vhlines(arg1, false, first, xmin, xmax, percent, KW(kwargs))
14701470
end
14711471
hlines!(arg=nothing; ymin=NaN, ymax=NaN, percent=false, kw...) = hlines(arg; first=false, ymin=ymin, ymax=ymax, percent=percent, kw...)
14721472
# ------------------------------------------------------------------------------------------------------
@@ -1494,13 +1494,12 @@ Example:
14941494
"""
14951495
function vlines(arg1=nothing; first=true, ymin=NaN, ymax=NaN, percent=false, kwargs...)
14961496
# A lines plotting method of plot
1497-
helper_vhlines(arg1, true, first, ymin, ymax, percent, kwargs...)
1497+
helper_vhlines(arg1, true, first, ymin, ymax, percent, KW(kwargs))
14981498
end
14991499
vlines!(arg=nothing; ymin=NaN, ymax=NaN, percent=false, kw...) = vlines(arg; first=false, ymin=ymin, ymax=ymax, percent=percent, kw...)
15001500

15011501
# ------------------------------------------------------------------------------------------------------
1502-
function helper_vhlines(arg1, vert::Bool, first::Bool, xymin, xymax, percent, kwargs...)
1503-
d = KW(kwargs)
1502+
function helper_vhlines(arg1, vert::Bool, first::Bool, xymin, xymax, percent, d)
15041503
(arg1 === nothing && ((arg1_ = find_in_dict(d, [:data])[1]) === nothing)) && error("No input data")
15051504
# If I don't do this stupid gymn with arg1 vs arg1_ then arg1 is Core.Boxed F..
15061505
len::Int = (arg1 !== nothing) ? length(arg1) : length(arg1_)
@@ -1788,8 +1787,6 @@ const psternary! = ternary! # Aliases
17881787
17891788
Plot event symbols and labels for a moment in time
17901789
1791-
See full GMT docs at [`events`]($(GMTdoc)events.html)
1792-
17931790
Parameters
17941791
----------
17951792
@@ -1836,9 +1833,9 @@ Parameters
18361833
- $(opt_savefig)
18371834
"""
18381835
# ------------------------------------------------------------------------------------------------------
1839-
function events(cmd0::String="", arg1=nothing; kwargs...)
1836+
events(cmd0::String="", arg1=nothing; kwargs...) = events(cmd0, arg1, KW(kwargs))
1837+
function events(cmd0::String, arg1, d::Dict{Symbol, Any})
18401838
# events share a lot of options with plot
1841-
d = KW(kwargs)
18421839
cmd::String = add_opt(d, "", "T", [:T :now])
18431840
if (!occursin("-T", cmd)) error("The 'now' (T) option is mandatory") end
18441841
cmd = add_opt(d, cmd, "E", [:E :knots],

src/pscontour.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Reads a table data and produces a raw contour plot by triangulation.
55
6-
See full GMT docsat [`contour`]($(GMTdoc)contour.html)
7-
86
Parameters
97
----------
108

src/psmask.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Clip or mask map areas with no data table coverage
55
6-
See full GMT docs at [`psmask`]($(GMTdoc)mask.html)
7-
86
Parameters
97
----------
108

src/sealand.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ colorbar!(pos=(inside=true, anchor=:TR, offset=(0.8,0.2), size=(10,0.5), horizon
3838
3939
"""
4040
sealand(f1::Function, arg1, t1::NamedTuple, f2::Function, arg2, t2::NamedTuple; kw...) =
41-
helper_sealand("sealand", f1, arg1, t1, f2, arg2, t2; kw...)
41+
helper_sealand("sealand", f1, arg1, t1, f2, arg2, t2, KW(kw))
4242
terramar(f1::Function, arg1, t1::NamedTuple, f2::Function, arg2, t2::NamedTuple; kw...) =
43-
helper_sealand("terramar", f1, arg1, t1, f2, arg2, t2; kw...)
43+
helper_sealand("terramar", f1, arg1, t1, f2, arg2, t2, KW(kw))
4444

45-
function helper_sealand(whichfun::String, f1::Function, arg1, t1::NamedTuple, f2::Function, arg2, t2::NamedTuple; kw...)
46-
d = KW(kw)
45+
function helper_sealand(whichfun::String, f1::Function, arg1, t1::NamedTuple, f2::Function, arg2, t2::NamedTuple, d::Dict{Symbol, Any})
4746
see = ((val = find_in_dict(d, [:show])[1]) !== nothing) ? ((val == 1) ? true : false) : false
4847
fname = find_in_dict(d, [:savefig :figname :name])[1];
4948
f1(arg1; t1...)

src/spectrum1d.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Compute auto- [and cross- ] spectra from one [or two] time-series.
55
6-
See full GMT docs at [`spectrum1d`]($(GMTdoc)spectrum1d.html)
7-
86
Parameters
97
----------
108

src/sphdistance.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Create Voronoi distance, node, or natural nearest-neighbor grid on a sphere
55
6-
See full GMT docs at [`sphdistance`]($(GMTdoc)sphdistance.html)
7-
86
Parameters
97
----------
108

src/sphinterpolate.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Spherical gridding in tension of data on a sphere
55
6-
See full GMT docs at [`sphinterpolate`]($(GMTdoc)sphinterpolate .html)
7-
86
Parameters
97
----------
108

0 commit comments

Comments
 (0)