Skip to content

add methods to < and <= instead of to > and >=#1802

Merged
joa-quim merged 1 commit into
GenericMappingTools:masterfrom
nsajko:add_methods_to_the_intended_function
Sep 8, 2025
Merged

add methods to < and <= instead of to > and >=#1802
joa-quim merged 1 commit into
GenericMappingTools:masterfrom
nsajko:add_methods_to_the_intended_function

Conversation

@nsajko

@nsajko nsajko commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

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.

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.
@joa-quim

joa-quim commented Sep 7, 2025

Copy link
Copy Markdown
Member

Sorry, but this also removes the G > 10 or I > 10 syntax and that is whole point of the situation. I want to be able to do both
G > 10 or G < 100 (G(rid) or I(mage) is the same for this discussion). And as it is G < 100 is considered valid but G > 10, not.

Users could also do !(G <= 10) to get the same result, but users would say (or find out that they had to do it that way?)

@nsajko

nsajko commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

Sorry, but this also removes

Can you be more specific?

@joa-quim

joa-quim commented Sep 7, 2025

Copy link
Copy Markdown
Member

If we replace

Base.:>(I::GMTimage{T}, val::Real) where T <: Unsigned = mat2img(collect(I.image .> val), I)

by

Base.:<(val::Real, I::GMTimage{T}) where T <: Unsigned = mat2img(collect(I.image .> val), I)

the multidispach I::GMTimage > ... is gone and I > ... will be a No method .... error.

@nsajko

nsajko commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

Why do you think so? As discussed already, > has a generic definition, falling back to <.

@joa-quim

joa-quim commented Sep 8, 2025

Copy link
Copy Markdown
Member

Can't say I understand how the fallback worked, but you are right. This works to keep the > and >= syntax.
Thanks a lot

(I'm now down to 31 SnoopCompile invalidations, but that doesn't change a bit in 59494)

@joa-quim joa-quim merged commit 0e0bec9 into GenericMappingTools:master Sep 8, 2025
1 check passed
@nsajko nsajko deleted the add_methods_to_the_intended_function branch September 8, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants