Skip to content

Commit 6e8fb0f

Browse files
authored
Merge pull request #1985 from GenericMappingTools/fix-regressions
Fix regressions in rescale, vlines, and a mat2ds method
2 parents b648008 + ca32d69 commit 6e8fb0f

5 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/GMT.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ include("common_options.jl")
205205
const LEGEND_TYPE = Ref{legend_bag}(legend_bag())# To store Legends info
206206
include("beziers.jl")
207207
include("brokenaxes.jl")
208+
include("choropleth_utils.jl")
208209
include("circfit.jl")
209210
include("crop.jl")
210211
include("custom_symb_funs.jl")
@@ -327,7 +328,7 @@ include("trend2d.jl")
327328
include("xyz2grd.jl")
328329
include("utils.jl")
329330
include("utils_project.jl")
330-
include("choropleth_utils.jl")
331+
#include("xkcd.jl")
331332
include("drawing/Drawing.jl")
332333
include("extras/anaglyph.jl")
333334
include("extras/analemma.jl")
@@ -448,6 +449,7 @@ end
448449
#Base.precompile(Tuple{Dict{Symbol, Any}, Vector{String}}) # Here it doesn't print anything.
449450
#Base.precompile(Tuple{typeof(Base.vect), Array{String, 1}, Vararg{Array{String, 1}}})
450451
Base.precompile(Tuple{typeof(GMT.axis), Base.Dict{Symbol, Any}, Bool, Bool, Bool, Bool, Base.Dict{Symbol, Any}})
452+
Base.precompile(Tuple{typeof(GMT.axis), NamedTuple{(:axes, :annot, :grid), Tuple{Symbol, Symbol, Int64}}, Base.Dict{Symbol, Any}})
451453

452454
function __init__(test::Bool=false)
453455
clear_sessions(3600)# Delete stray sessions dirs older than 1 hour

src/plot.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ end
105105
function _plot(arg1, first::Bool, d::Dict{Symbol, Any})
106106
# Broken axis — intercept before anything else
107107
is_in_dict(d, [:breakx :breaky :xranges :yranges]; del=false) !== nothing && return _brokenplot(mat2ds(arg1), first, d)
108+
# xkcd style
109+
#is_in_dict(d, [:xkcd]; del=false) !== nothing && return _xkcd_plot(arg1, first, d)
108110
# First check if arg1 is a GMTds of a linear fit and if yes, call the plotlinefit() fun
109111
if (isa(arg1, GDtype) && is_in_dict(d, [:linefit :regress]; del=false) !== nothing)
110112
att = isa(arg1, GMTdataset) ? arg1.attrib : arg1[1].attrib
@@ -1532,7 +1534,12 @@ function helper_vhlines(arg1, vert::Bool, first::Bool, xymin, xymax, percent, d)
15321534
!isnan(xymin) && (xy[1] = !percent ? xymin : xy[1] + (xy[2]-xy[1]) * xymin)
15331535
!isnan(xymax) && (xy[2] = !percent ? xymax : xy[1] + (xy[2]-xy[1]) * xymax)
15341536
D::GMTdataset = mat2ds(mat, x=xy, multi=true, nanseg=true)[1]
1535-
vert && (d[:yx] = true) # Because we need to swapp x / y columns in the vlines case
1537+
#vert && (d[:yx] = true) # Because we need to swapp x / y columns in the vlines case
1538+
if (vert)
1539+
for k = 1:size(D,1)
1540+
D.data[k,1], D.data[k,2] = D.data[k,2], D.data[k,1]
1541+
end
1542+
end
15361543
delete!(d, [[:xmin], [:xmax], [:ymin], [:ymax]])
15371544

15381545
common_plot_xyz("", D, "lines", first, false, d)

src/pshistogram.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ function histogram_helper(cmd0::String, arg1, O::Bool, K::Bool, d::Dict{Symbol,A
165165
do_auto = ((val_auto = find_in_dict(d, [:auto :thresholds])[1]) !== nothing) ? true : false # Automatic bounds detetion
166166
(val_auto == 1) && (val_auto = nothing) # If auto=true, we want to pass a nothing to the find_histo_limits() fun
167167
do_getauto = ((val_getauto = find_in_dict(d, [:getauto :getthresholds])[1]) !== nothing) ? true : false
168+
do_getauto && (val_getauto = nothing) # If getauto=true, we want to pass a nothing to the find_histo_limits() fun
168169
do_zoom = ((find_in_dict(d, [:zoom])[1]) !== nothing) ? true : false # Automatic zoom to interesting region
169170

170171
function if_zoom(cmd, opt_R, limit_L, limit_R, hst)

src/utils.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,10 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
755755
elseif (isa(stretch, Tuple) || (isvector(stretch) && length(stretch) == 2))
756756
_inputmin, _inputmax = stretch[1], stretch[2]
757757
end
758-
(isnan(inputmin)) && (mi::Float64 = (isa(A, GItype)) ? A.range[5] : minimum_nan(A))
759-
(isnan(inputmax)) && (ma::Float64 = (isa(A, GItype)) ? A.range[6] : maximum_nan(A))
760-
_inmin::Float64 = (isnan(inputmin)) ? mi : _inputmin
761-
_inmax::Float64 = (isnan(inputmax)) ? ma : _inputmax
758+
(isnan(_inputmin)) && (mi::Float64 = (isa(A, GItype)) ? A.range[5] : minimum_nan(A))
759+
(isnan(_inputmax)) && (ma::Float64 = (isa(A, GItype)) ? A.range[6] : maximum_nan(A))
760+
_inmin::Float64 = (isnan(_inputmin)) ? mi : _inputmin
761+
_inmax::Float64 = (isnan(_inputmax)) ? ma : _inputmax
762762
d1 = _inmax - _inmin
763763
(d1 <= 0.0) && error("Stretch range has inputmin > inputmax.")
764764
d2 = up - low
@@ -775,7 +775,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
775775
sc *= _tmax
776776
low *= _tmax
777777
if (have_nans)
778-
if (isnan(inputmin) && isnan(inputmax))
778+
if (isnan(_inputmin) && isnan(_inputmax))
779779
if (type == UInt8)
780780
@inbounds for k = 1:numel(A) isnan(A[k]) && (o[k] = 0; continue); o[k] = round(UInt8, low + (A[k] -_inmin) * sc) end
781781
else
@@ -789,7 +789,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
789789
end
790790
end
791791
else
792-
if (isnan(inputmin) && isnan(inputmax))
792+
if (isnan(_inputmin) && isnan(_inputmax))
793793
if (type == UInt8)
794794
@inbounds for k = 1:numel(A) o[k] = round(UInt8, low + (A[k] -_inmin) * sc) end
795795
else
@@ -807,7 +807,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
807807
oType = (eltype(A) <: AbstractFloat) ? eltype(A) : Float64
808808
o = Array{oType}(undef, size(A))
809809
if (oType <: Integer && have_nans) # Shitty case
810-
if (isnan(inputmin) && isnan(inputmax)) # Faster case.
810+
if (isnan(_inputmin) && isnan(_inputmax)) # Faster case.
811811
@inbounds for k = 1:numel(A) isnan(A[k]) && (o[k] = 0; continue); o[k] = low + (A[k] -_inmin) * sc end
812812
else
813813
@inbounds for k = 1:numel(A)
@@ -816,7 +816,7 @@ function rescale(A::AbstractArray; low=0.0, up=1.0, inputmin=NaN, inputmax=NaN,
816816
end
817817
end
818818
else
819-
if (isnan(inputmin) && isnan(inputmax)) # Faster case. No IFs in loop
819+
if (isnan(_inputmin) && isnan(_inputmax)) # Faster case. No IFs in loop
820820
@inbounds for k = 1:numel(A) o[k] = low + (A[k] -_inmin) * sc end
821821
else
822822
@inbounds for k = 1:numel(A)

src/utils_types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ function _mat2img_u16(@nospecialize(mat), x::Vector{Float64}, y::Vector{Float64}
14441444
# Use the keyword `noconv=true` to return GMTimage UInt16 type. I.e., no conversion to UInt8
14451445

14461446
if ((is_in_dict(d, [:noconv])) !== nothing) # No conversion to UInt8 is wished
1447-
return helper_mat2img(mat, x, y, v, hdr, proj4, wkt, GMTcpt(), false, d)
1447+
return helper_mat2img(mat, x, y, v, hdr, proj4, wkt, GMTcpt(), get(d, :is_transposed, false), d)
14481448
end
14491449

14501450
img = isempty(img8) ? Array{UInt8, ndims(mat)}(undef, size(mat)) : img8

0 commit comments

Comments
 (0)