Skip to content

Commit 0e0bec9

Browse files
authored
add methods to < and <= instead of to > and >= (#1802)
As documented, the intended way to implement `>` is to add a method to `<`. Similarly with `>=`. This should solve some of the problems mentioned on issue #1799. However, for the long term (whenever a breaking release of GMT.jl happens), I'd suggest just getting rid of the methods, as discussed on issue #1799.
1 parent 4545e06 commit 0e0bec9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/grd_operations.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,26 +195,26 @@ end
195195
Base.:<=(I::GMTimage{T}, val::Real) where T <: Unsigned = mat2img(collect(I.image .<= val), I)
196196

197197
# ---------------------------------------------------------------------------------------------------
198-
function Base.:>(G1::GMTgrid, val::Number)
198+
function Base.:<(val::Number, G1::GMTgrid)
199199
epsg, geog, range, inc, registration, nodata, x, y, v, pad = dup_G_meta(G1)
200200
G2 = GMTgrid(G1.proj4, G1.wkt, epsg, geog, range, inc, registration, nodata, "", "", "", "", G1.names, x, y, v,
201201
UInt8.(G1.z .> val), G1.x_unit, G1.y_unit, G1.v_unit, G1.z_unit, G1.layout, 1f0, 0f0, pad, G1.hasnans)
202202
setgrdminmax!(G2)
203203
return G2
204204
end
205205
# For images
206-
Base.:>(I::GMTimage{T}, val::Real) where T <: Unsigned = mat2img(collect(I.image .> val), I)
206+
Base.:<(val::Real, I::GMTimage{T}) where T <: Unsigned = mat2img(collect(I.image .> val), I)
207207

208208
# ---------------------------------------------------------------------------------------------------
209-
function Base.:>=(G1::GMTgrid, val::Number)
209+
function Base.:<=(val::Number, G1::GMTgrid)
210210
epsg, geog, range, inc, registration, nodata, x, y, v, pad = dup_G_meta(G1)
211211
G2 = GMTgrid(G1.proj4, G1.wkt, epsg, geog, range, inc, registration, nodata, "", "", "", "", G1.names, x, y, v,
212212
UInt8.(G1.z .>= val), G1.x_unit, G1.y_unit, G1.v_unit, G1.z_unit, G1.layout, 1f0, 0f0, pad, G1.hasnans)
213213
setgrdminmax!(G2)
214214
return G2
215215
end
216216
# For images
217-
Base.:>=(I::GMTimage{T}, val::Real) where T <: Unsigned = mat2img(collect(I.image .>= val), I)
217+
Base.:<=(val::Real, I::GMTimage{T}) where T <: Unsigned = mat2img(collect(I.image .>= val), I)
218218

219219
# ---------------------------------------------------------------------------------------------------
220220
"""

0 commit comments

Comments
 (0)