-
Notifications
You must be signed in to change notification settings - Fork 20
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
unstack
not passing the inferred test
#149
Comments
Adding a method which takes a |
Thanks! Would this be OK? unstack(xs; dims::Val{D}) where D = [copy(selectdim(xs, D, i)) for i in 1:size(xs, D)] |
If it infers for you and passes the existing tests (with Val instead of Int dims), then drop a PR :) |
I don't understand why when I add the new method unstack(xs; dims::Int) = [copy(selectdim(xs, dims, i)) for i in 1:size(xs, dims)]
unstack(xs; dims::Val{D}) where {D} = [copy(selectdim(xs, D, i)) for i in 1:size(xs, D)] when I run the tests, the previous method with dims::Int is not found: Test threw exception
Expression: stack(unstack(stacked_array, dims = 1), dims = 1) == stacked_array
MethodError: no method matching var"#unstack#102"(::Int64, ::typeof(unstack), ::Matrix{Int64})
Closest candidates are:
var"#unstack#102"(::Val{D}, ::typeof(unstack), ::Any) where D at ~/Documents/issues/MLUtils.jl/src/utils.jl:80 It's like the new method would be overwriting the other one. But that doesn't make sense because they should be considered as two different methods, with different signatures. For example, the following works well: julia> f(x::Int) = "int"
julia> f(x::Val{d}) where d = "val"
julia> f(2)
"int"
julia> f(Val(2))
"val" Do you know what is the problem in the case of |
I've just realized that it's due to the keyword argument. I guess I'll have to make that method with dims not being a keyword argument. I'll make the PR now :) |
Bellow you can find a MWE. Is there any workaround?
The text was updated successfully, but these errors were encountered: