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

Run Aqua tests #20

Closed
rafaqz opened this issue Apr 7, 2024 · 4 comments
Closed

Run Aqua tests #20

rafaqz opened this issue Apr 7, 2024 · 4 comments

Comments

@rafaqz
Copy link
Member

rafaqz commented Apr 7, 2024

Currenty aqua tests are not actually run, and there are a lot of ambiguities.

This affects all packages depending on CommonDataModels and also using Aqua. It would also be good to run the other Aqua checks at the same time.

julia> Aqua.test_ambiguities(CommonDataModel)
22 ambiguities found
Ambiguity #1
broadcasted(f::Function, A, B::CommonDataModel.ReducedGroupedVariable) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:503
broadcasted(f::Function, A::CommonDataModel.ReducedGroupedVariable, B) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:505

Possible fix, define
  broadcasted(::Function, ::CommonDataModel.ReducedGroupedVariable, ::CommonDataModel.ReducedGroupedVariable)

Ambiguity #2
broadcasted(::typeof(LinearAlgebra.:*ₛ), out, beta) @ LinearAlgebra /opt/julia/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:10
broadcasted(f::Function, A::CommonDataModel.ReducedGroupedVariable, B) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:505

Possible fix, define
  broadcasted(::typeof(LinearAlgebra.:*ₛ), ::CommonDataModel.ReducedGroupedVariable, ::Any)

Ambiguity #3
broadcasted(::typeof(LinearAlgebra.:*ₛ), out, beta) @ LinearAlgebra /opt/julia/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:10
broadcasted(f::Function, A, B::CommonDataModel.ReducedGroupedVariable) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:503

Possible fix, define
  broadcasted(::typeof(LinearAlgebra.:*ₛ), ::Any, ::CommonDataModel.ReducedGroupedVariable)

Ambiguity #4
checkbounds(::Type{Bool}, RA::CommonDataModel.ResizableArray, inds...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:5
checkbounds(::Type{Bool}, A::AbstractArray, I::Base.LogicalIndex) @ Base multidimensional.jl:849

Possible fix, define
  checkbounds(::Type{Bool}, ::CommonDataModel.ResizableArray, ::Base.LogicalIndex)

Ambiguity #5
checkbounds(::Type{Bool}, RA::CommonDataModel.ResizableArray, inds...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:5
checkbounds(::Type{Bool}, A::AbstractArray, I::Base.LogicalIndex{<:Any, <:AbstractVector{Bool}}) @ Base multidimensional.jl:847

Possible fix, define
  checkbounds(::Type{Bool}, ::CommonDataModel.ResizableArray, ::Base.LogicalIndex{<:Any, <:AbstractVector{Bool}})

Ambiguity #6
checkbounds(::Type{Bool}, RA::CommonDataModel.ResizableArray, inds...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:5
checkbounds(::Type{Bool}, A::AbstractArray{<:Any, N}, I::AbstractArray{Bool, N}) where N @ Base abstractarray.jl:687

Possible fix, define
  checkbounds(::Type{Bool}, ::CommonDataModel.ResizableArray{<:Any, N}, ::AbstractArray{Bool, N}) where N

Ambiguity #7
checkbounds(::Type{Bool}, RA::CommonDataModel.ResizableArray, inds...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:5
checkbounds(::Type{Bool}, A::AbstractArray, i::Union{AbstractArray{<:CartesianIndex}, CartesianIndex}) @ Base multidimensional.jl:681

Possible fix, define
  checkbounds(::Type{Bool}, ::CommonDataModel.ResizableArray, ::Union{AbstractArray{<:CartesianIndex}, CartesianIndex})

Ambiguity #8
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, itr::Base.SkipMissing{<:AbstractArray}) @ Base missing.jl:395

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::Base.SkipMissing{<:AbstractArray})

Ambiguity #9
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, a::AbstractArray) @ Base array.jl:2682

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::AbstractArray)

Ambiguity #10
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, d::AbstractDict) @ Base abstractdict.jl:471

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::AbstractDict)

Ambiguity #11
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, a::Array{T, N}) where {T, N} @ Base array.jl:2670

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::Array{T, N}) where {T, N}

Ambiguity #12
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, t::Tuple) @ Base tuple.jl:464

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::Tuple)

Ambiguity #13
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, s::AbstractString) @ Base strings/basic.jl:666

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::AbstractString)

Ambiguity #14
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, Bs::BitArray) @ Base bitarray.jl:1825

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::BitArray)

Ambiguity #15
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(pred, s::AbstractSet) @ Base abstractset.jl:518

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::AbstractSet)

Ambiguity #16
filter(ncv::CommonDataModel.AbstractVariable, indices...; accepted_status_flags) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfconventions.jl:58
filter(f, s::Union{SubString{String}, String}) @ Base strings/substring.jl:279

Possible fix, define
  filter(::CommonDataModel.AbstractVariable, ::Union{SubString{String}, String})

Ambiguity #17
getindex(v::CommonDataModel.AbstractVariable, name::Union{AbstractString, Symbol}) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfvariable.jl:533
getindex(v::CommonDataModel.MemoryVariable, ij...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:56

Possible fix, define
  getindex(::CommonDataModel.MemoryVariable, ::Union{AbstractString, Symbol})

Ambiguity #18
getindex(ds::Union{CommonDataModel.AbstractDataset, CommonDataModel.AbstractVariable}, n::CommonDataModel.CFStdName) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/dataset.jl:243
getindex(v::CommonDataModel.MFCFVariable, ind...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/multifile.jl:252

Possible fix, define
  getindex(::CommonDataModel.MFCFVariable, ::CommonDataModel.CFStdName)

Ambiguity #19
getindex(ds::Union{CommonDataModel.AbstractDataset, CommonDataModel.AbstractVariable}, n::CommonDataModel.CFStdName) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/dataset.jl:243
getindex(v::CommonDataModel.MemoryVariable, ij...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/memory_dataset.jl:56

Possible fix, define
  getindex(::CommonDataModel.MemoryVariable, ::CommonDataModel.CFStdName)

Ambiguity #20
getindex(v::CommonDataModel.AbstractVariable, name::Union{AbstractString, Symbol}) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/cfvariable.jl:533
getindex(v::CommonDataModel.MFCFVariable, ind...) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/multifile.jl:252

Possible fix, define
  getindex(::CommonDataModel.MFCFVariable, ::Union{AbstractString, Symbol})

Ambiguity #21
reduce(f::Function, gv::CommonDataModel.GroupedVariable) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:428
reduce(::typeof(hcat), A::AbstractVector{<:AbstractVecOrMat}) @ Base abstractarray.jl:1718

Possible fix, define
  reduce(::typeof(hcat), ::CommonDataModel.GroupedVariable{TV, TF, TGM, TM, var"#s128"} where {var"#s128"<:(AbstractVecOrMat), TV, TF, TGM, TM})

Ambiguity #22
reduce(f::Function, gv::CommonDataModel.GroupedVariable) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:428
reduce(::typeof(vcat), A::AbstractVector{<:AbstractVecOrMat}) @ Base abstractarray.jl:1715

Possible fix, define
  reduce(::typeof(vcat), ::CommonDataModel.GroupedVariable{TV, TF, TGM, TM, var"#s128"} where {var"#s128"<:(AbstractVecOrMat), TV, TF, TGM, TM})

Test Failed at /home/raf/.julia/packages/Aqua/9p8ck/src/ambiguities.jl:77
  Expression: num_ambiguities == 0
   Evaluated: 22 == 0

ERROR: There was an error during testing
@Alexander-Barth
Copy link
Member

Indeed, I have already fixed some of them (the easy ones :-) ).

It is not clear how one can fix this:

Ambiguity #2
broadcasted(::typeof(LinearAlgebra.:*ₛ), out, beta) @ LinearAlgebra /opt/julia/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:10
broadcasted(f::Function, A::CommonDataModel.ReducedGroupedVariable, B) @ CommonDataModel ~/.julia/dev/CommonDataModel/src/groupby.jl:505

without importing the private operator *ₛ.

@rafaqz
Copy link
Member Author

rafaqz commented Apr 8, 2024

As far as I know adding methods to broadcasted isn't needed, and should be avoided? There is no way for both package A and package B to add your broadcasted methods without ambiguities between A.ArrayType and B.ArrayType.

And doesn't that dispatch mean that the inner groupby brodcasts only work for those specific methods? so it will be inconsistent in other broadcasts?

DimensionalData.jl and DiskArrays both have relatively complicated broadcast mechanisms and don't add broadcasted methods:
https://github.com/rafaqz/DimensionalData.jl/blob/main/src/array/broadcast.jl
https://github.com/meggart/DiskArrays.jl/blob/main/src/broadcast.jl

@Alexander-Barth
Copy link
Member

Alexander-Barth commented Apr 10, 2024

I think I should add a method to broadcasted(::SomeStyle,f,A,B) (rather than broadcasted(f,A::MyType,B::MyType)). Doing so fixes the ambiguity 2 and 3 .

(Thanks for the examples. They have been quite useful to better understand the broadcasting styles).

Alexander-Barth added a commit that referenced this issue Apr 12, 2024
Alexander-Barth added a commit that referenced this issue Apr 16, 2024
@Alexander-Barth
Copy link
Member

Aqua tests now all pass (and are enabled in CI) :-)

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

No branches or pull requests

2 participants