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
rework result_type #140
rework result_type #140
Conversation
The essence of `result_type` is based on the `eltype(a)`, and `result_type(::PreMetric, ::AbstractArray, ::AbstractArray)` only serves as an convenient method. There's no functionality changes in this commit, only to reorganize the codes to ease future development.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not. Couldn't we even find a generic definition using oneunit
and float
?
src/generic.jl
Outdated
```julia-repl | ||
julia> T = result_type(Euclidean(), Float32, Float64) | ||
Float64 | ||
julia> r = zeros(T, 2, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look relevant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that this is a docstring for an internal function, so it doesn't seem necessary to explain what can be the use of that function. Anyway, if you prefer showing an example calling pairwise
, please turn it into a runnable doctest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simply delete this part in the new commit; the only reason I added this seeming-too-obvious example is because result_type
is exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't realized it was exported. Anyway, looks good that way.
I tried, but then I realized it's better not to change the behavior of those algorithms in the first PR. You're suggesting some breaking changes though. |
The essence of
result_type
is based on theeltype(a)
, andresult_type(::PreMetric, ::AbstractArray, ::AbstractArray)
only serves as an convenient method.There are no functionality changes in this commit, only to reorganize the codes to ease future development.
For example, in
ImageDistances.jl
, we can easily extendresult_type
toColorant
types if we dispatch onType
:In the meantime, dispatching on
AbstractArray
would introduces a lot of method ambiguities.