-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support and document a vector-based API #180
Comments
Thanks for your issue. I just noticed that the stable docs are out of date (#181), so please refer to the dev docs. There is a kwarg Now towards your main point: There already is the function you want to have as an internal (called in Line 88 in 3cd8d0e
Furthermore, for counting ambiguities in your code, you can just use |
...
I agree that my suggestion of using the number of ambiguities (or instances of type piracy, unbound method args etc.) is a less precise than using the Let's take method ambiguities for a package I'm working on, for example: method_ambiguity = ((::Type{T})(x::Static.StaticInteger) where T<:Real @ Static ~/.julia/packages/Static/dLrtk/src/Static.jl:421, (var"#ctor-self#"::Type{ClimaCore.Utilities.PlusHalf{I}} where I<:Integer)(i) @ ClimaCore.Utilities dev/ClimaCore.jl/src/Utilities/plushalf.jl:13)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle{N}, op, x::Number, r::FillArrays.AbstractFill{T, N}) where {T, N} @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:236, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (ldiv!(L::LinearAlgebra.LU{<:Any, <:ArrayLayouts.LayoutMatrix}, B::ArrayLayouts.LayoutVector) @ ArrayLayouts ~/.julia/packages/ArrayLayouts/LXeCF/src/factorizations.jl:444, ldiv!(A::LinearAlgebra.LU, x::ClimaCore.Fields.FieldVector) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:259)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle{N}, op, r::FillArrays.AbstractFill{T, N}, x::Number) where {T, N} @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:235, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle{N}, op, r::FillArrays.AbstractFill{T, N}, x::Ref) where {T, N} @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:237, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (copyto!(dest::AbstractArray, bc::Base.Broadcast.Broadcasted{<:BlockArrays.AbstractBlockStyle{NDims}, <:Any, <:Any, Args}) where {NDims, Args<:Tuple} @ BlockArrays ~/.julia/packages/BlockArrays/4FBcw/src/blockbroadcast.jl:190, copyto!(dest::ClimaCore.Fields.FieldVector, bc::Base.Broadcast.Broadcasted{<:Base.Broadcast.AbstractArrayStyle{0}}) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:218)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle, op, a::FillArrays.AbstractFill, b::FillArrays.AbstractFill) @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:95, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (copyto!(dest::AbstractArray, bc::Base.Broadcast.Broadcasted{<:GPUArraysCore.AbstractGPUArrayStyle}) @ GPUArrays ~/.julia/packages/GPUArrays/5XhED/src/host/broadcast.jl:46, copyto!(dest::ClimaCore.Fields.FieldVector, bc::Base.Broadcast.Broadcasted{<:Base.Broadcast.AbstractArrayStyle{0}}) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:218)
method_ambiguity = (copyto!(dest::AbstractArray, B::Base.Broadcast.Broadcasted{<:StaticArraysCore.StaticArrayStyle}) @ StaticArrays ~/.julia/packages/StaticArrays/dTwvg/src/broadcast.jl:65, copyto!(dest::ClimaCore.Fields.FieldVector, bc::Base.Broadcast.Broadcasted{<:Base.Broadcast.AbstractArrayStyle{0}}) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:218)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle{N}, op, x::Ref, r::FillArrays.AbstractFill{T, N}) where {T, N} @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:238, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (broadcasted(::Base.Broadcast.DefaultArrayStyle{N}, op, r::FillArrays.AbstractFill{T, N}) where {T, N} @ FillArrays ~/.julia/packages/FillArrays/FwMoZ/src/fillbroadcast.jl:78, broadcasted(fs::Base.Broadcast.DefaultArrayStyle{0}, ::Type{T}, args...) where T<:AxisTensor @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/broadcast.jl:294)
method_ambiguity = (ldiv!(L::LinearAlgebra.LU{<:Any, <:ArrayLayouts.LayoutMatrix}, B) @ ArrayLayouts ~/.julia/packages/ArrayLayouts/LXeCF/src/factorizations.jl:422, ldiv!(A::LinearAlgebra.LU, x::ClimaCore.Fields.FieldVector) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:259)
method_ambiguity = (ldiv!(L::LinearAlgebra.LU{<:Any, <:SubArray{<:Any, 2, <:ArrayLayouts.LayoutMatrix}}, B) @ ArrayLayouts ~/.julia/packages/ArrayLayouts/LXeCF/src/factorizations.jl:422, ldiv!(A::LinearAlgebra.LU, x::ClimaCore.Fields.FieldVector) @ ClimaCore.Fields dev/ClimaCore.jl/src/Fields/fieldvector.jl:259) With my suggested interface, adding this test is as simple as ambs = Aqua.detect_ambiguities(ClimaCore; recursive = true)
@test length(ambs) ≤ 13 How would this look using the exclude kwarg?
Yes, I'm aware of this function, I just like the idea of this package having a clear, simple, and consistent API. I think using the Can we at least add support for these style of tests? |
Not for nothing, but I have the same issue with JETjl. Is it actually realistic for me to add excludes when |
I can have a look when I find some time if/how we can offer such functions as part of the public API without fixing too much of the Aqua internals. |
Actually I don't think If instead I could get a dictionary with entries of the form Of course even more powerful would be if the full list of ambiguities could be put into a serialized form, including information on the full signature (so that I can recognize the case when in one PR, one ambiguity is fixed but another one is introduced). However, this is to me really optional, as that seems like a relatively scarce scenarios... Also, we shouldn't let the perfect be the enemy of the good, i.e. some imperfect improvement here (which can be improved incrementally over time) beats a never implemented perfect solution any day. |
While the existing interface is ideal if users are work on packages with no instances of method ambiguities, piracy and unbound method argument types. That is just not the case. The interface
@test_X(SomePackage)
(e.g.,@test_ambiguities(SomePackage)
) works in the case that a package is able to pass this test, but it's otherwise unhelpful.Similarly, I've seen
@test_broken isempty(Aqua.detect_ambiguities(SomePackage))
, while this works for packages that don't pass@test_ambiguities
, however it still has downsides:I would like to propose changing this package's api (and update documentation to encourage users to fix their issues) to always return a vector of the offending issues, similar to how
Aqua.detect_ambiguities(SomePackage)
works. We can then document Aqua.jl's use as:This way, users can incrementally fix issues they may have, while preventing new ones from entering.
The text was updated successfully, but these errors were encountered: