Skip to content
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

relax result_type dist types #185

Closed
wants to merge 2 commits into from

Conversation

johnnychen94
Copy link
Contributor

@johnnychen94 johnnychen94 commented Oct 14, 2020

I'm working on an extension package to Distances to handle massive pointwise calculation where the output is of size at O(m^2*n^2), and I find it could be quite useful to reuse this result_type here, so this PR is just relaxing it a bit to accept any kind of function dist.

Not very sure if this is a wanted change. I can make up my own result_type function there but I guess to get this done here it would be helpful also to other potential usages.

For Distances own purpose, now it is possible to

julia> result_type(euclidean, Int, Int)
Float64

@johnnychen94
Copy link
Contributor Author

Without feedback in two weeks, I guess this is probably not a good idea to Distances.jl, so I'm going to close it.

@dkarrasch
Copy link
Member

For Distances own purpose, now it is possible to

julia> result_type(euclidean, Int, Int)
Float64

I think this is somehow consistent with the types being callable:

julia> euclidean(2, 3)
1.0

julia> Euclidean()(2, 3)
1.0

julia> result_type(Euclidean(), Int, Int)
Float64

julia> result_type(euclidean, Int, Int)
ERROR: MethodError: no method matching result_type(::typeof(euclidean), ::Type{Int64}, ::Type{Int64})

So, I'm in favor.

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.

None yet

2 participants