sylvaticus / BetaML.jl

Beta Machine Learning Toolkit
MIT License
94 stars 14 forks source link

"`findall` is ambiguous" error #69

Closed simonsteiger closed 9 months ago

simonsteiger commented 9 months ago

While working with BetaML, DataFrames and Chain, I found that importing BetaML leads to ambiguity in findall when working with the @chain macro.

using Chain, DataFrames

import BetaML as BML

df = DataFrame(randn(100, 3), :auto)

# This works
transform(df, All() => ByRow((x...) -> sum(x)) => :y)

# This fails
@chain df begin
    transform(_, All() => ByRow((x...) -> sum(x)) => :y)
end

I am not sure what the correct solution would be. The error log suggests defining findall(::F, ::Array{T}) where {T, F<:Function}, but I am not experienced in managing packages and therefore not sure if one would have to keep other things in mind.

Here is the full error log:

LoadError: MethodError: findall(::Chain.var"#4#5", ::Vector{Any}) is ambiguous.

Candidates:
  findall(testf::Function, A)
    @ Base array.jl:2439
  findall(testf::F, A::AbstractArray) where F<:Function
    @ Base array.jl:2447
  findall(el::T, cont::Array{T}; returnTuple) where T
    @ BetaML.Utils ~/.julia/packages/BetaML/QcevM/src/Utils/Processing.jl:73

Possible fix, define
  findall(::F, ::Array{T}) where {T, F<:Function}
sylvaticus commented 9 months ago

hello, thank you to report... I ill look at this, but most likely not earlier than Monday...

sylvaticus commented 9 months ago

I think it's my fault, doing what it is called in Julia jargon "type piracy".. my bad, I have removed the old, unused offending functions and I am going to issue a new release of BetaML (v0.11.3), just wait a few minutes and update your project..

simonsteiger commented 9 months ago

Thanks a lot for the quick help and the great package!