-
Notifications
You must be signed in to change notification settings - Fork 22
Reimplement abs2 #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this a naming issue? I mean, do you need the overloaded methods of As you may have already read, the |
Yes, so for the time being I have added the Thanks for linking me to #126, that helps me understand the ambiguities. I will leave it up to the maintainers to decide if there is a reasonable, general |
Perhaps, if we define Personally, I think it is better to define it locally (i.e. without overloading _abs2(c) = mapreducec(v->float(v)^2, +, 0, c) cc: @timholy |
Not overriding the default Said that, I think it's the clearest way for future extension to other definitions/implementations so I'm good with the change; there's no need to bring |
gripe: julia> svd(rand(Gray, 32, 32))
ERROR: MethodError: no method matching abs2(::Gray{Float64})
Closest candidates are:
abs2(::Bool) at bool.jl:80
abs2(::Real) at number.jl:151
abs2(::Complex) at complex.jl:265
...
Stacktrace:
[1] eigtype(T::Type)
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/eigen.jl:302
[2] svd(A::Matrix{Gray{Float64}}; full::Bool, alg::LinearAlgebra.DivideAndConquer)
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/svd.jl:157
[3] svd(A::Matrix{Gray{Float64}})
@ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/svd.jl:157
[4] top-level scope
@ REPL[8]:1 I think we should consider proposing a abs2(x) = abs2(*, x)
abs2(f, x) = f(x, x) |
I think we can at least (safely) bring back |
One of the annoying things about this problem is that ColorVectorSpace.jl/src/ColorVectorSpace.jl Line 194 in dad1e06
Even if it is a Edit: However, I doubt that it will match what most users want. |
This will bring back |
@johnnychen94, do you think that |
JuliaImages/Images.jl#955 is just a temporary patch. Many of the codes there will soon be deprecated(I'm working on it) and thus removed in the future. I'm okay to this change but I don't think there's an urgent need for it; abs for Gray is not ambiguous. If you decide to remove that, since now most packages (in JuliaImages) don't directly rely on CVS, I can patch it appropriately and make it non-breaking in ImageCore side. |
I've always been a big fan of compatibility, so I'm not aggressive about removing
I think channel-wise I'm not going to rush to do anything about |
As a first step, I merged PR #164. I leave this issue open. |
I'd support having it for Gray. RGB is a much trickier issue. |
I realize that people are suffering from this and can't figure out a solution very quickly. Maybe it's a good idea to provide a few non-exported names for compatibility with the old codebase and other ecosystems? For example, provide |
Can anyone who has been suffering from this try the definition |
No one took the bait, but I've pushed an implementation in #172. Perhaps folks can give it a try for a bit before we merge. |
This PR #131 removed
abs2
because of some ambiguities. Although it's not clear to me what those ambiguities are, I think this is a useful method to have. Is it possible to define an implementation without those prior ambiguities?The text was updated successfully, but these errors were encountered: