ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

Method ambiguities reported by Aqua

Open prbzrg opened this issue 2 years ago • 3 comments

In Julia v1.10, I used Aqua to detect method ambiguities in my package https://github.com/impICNF/ContinuousNormalizingFlows.jl/issues/356 and some of its report were related to this package:

Ambiguity #7
==(x::ForwardDiff.Dual{Tx}, y::Real) where Tx @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:144
==(x::Real, y::AbstractIrrational) @ Base irrationals.jl:90

Possible fix, define
  ==(::ForwardDiff.Dual{Tx}, ::AbstractIrrational) where Tx

Ambiguity #13
==(x::Real, y::ForwardDiff.Dual{Ty}) where Ty @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
==(x::AbstractIrrational, y::Real) @ Base irrationals.jl:89

Possible fix, define
  ==(::AbstractIrrational, ::ForwardDiff.Dual{Ty}) where Ty

Ambiguity #18
ForwardDiff.Dual(args...) @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:73
(::Type{T})(x::T) where T<:Number @ Core boot.jl:792

Possible fix, define
  ForwardDiff.Dual(::ForwardDiff.Dual)

Ambiguity #19
(ForwardDiff.Dual{T, V})(x) where {T, V} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:79
(::Type{T})(x::T) where T<:Number @ Core boot.jl:792

Possible fix, define
  (ForwardDiff.Dual{T, V})(::ForwardDiff.Dual{T, V}) where {T, V}

Ambiguity #20
ForwardDiff.Dual{T, V, N}(x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:77
(::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:265

Possible fix, define
  ForwardDiff.Dual{T, V, N}(::Base.TwicePrecision) where {T, V, N}

Ambiguity #21
(ForwardDiff.Dual{T})(value) where T @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:69
(::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:265

Possible fix, define
  (ForwardDiff.Dual{T})(::Base.TwicePrecision) where T

Ambiguity #22
(ForwardDiff.Dual{T, V})(x) where {T, V} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:79
(::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:265

Possible fix, define
  (ForwardDiff.Dual{T, V})(::Base.TwicePrecision) where {T, V}

Ambiguity #23
ForwardDiff.Dual(args...) @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:73
(::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:265

Possible fix, define
  ForwardDiff.Dual(::Base.TwicePrecision)

Ambiguity #24
(ForwardDiff.Dual{T, V})(x) where {T, V} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:79
(::Type{T})(z::Complex) where T<:Real @ Base complex.jl:44

Possible fix, define
  (ForwardDiff.Dual{T, V})(::Complex) where {T, V}

Ambiguity #25
ForwardDiff.Dual(args...) @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:73
(::Type{T})(z::Complex) where T<:Real @ Base complex.jl:44

Possible fix, define
  ForwardDiff.Dual(::Complex)

Ambiguity #26
ForwardDiff.Dual{T, V, N}(x::Number) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:78
(::Type{T})(z::Complex) where T<:Real @ Base complex.jl:44

Possible fix, define
  ForwardDiff.Dual{T, V, N}(::Complex) where {T, V, N}

Ambiguity #27
ForwardDiff.Dual{T, V, N}(x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:77
(::Type{T})(z::Complex) where T<:Real @ Base complex.jl:44

Possible fix, define
  ForwardDiff.Dual{T, V, N}(::Complex) where {T, V, N}

Ambiguity #28
(ForwardDiff.Dual{T})(value) where T @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:69
(::Type{T})(z::Complex) where T<:Real @ Base complex.jl:44

Possible fix, define
  (ForwardDiff.Dual{T})(::Complex) where T

Ambiguity #29
ForwardDiff.Dual{T, V, N}(x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:77
(::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} @ Base char.jl:50

Possible fix, define
  ForwardDiff.Dual{T, V, N}(::AbstractChar) where {T, V, N}

Ambiguity #30
ForwardDiff.Dual(args...) @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:73
(::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} @ Base char.jl:50

Possible fix, define
  ForwardDiff.Dual(::AbstractChar)

Ambiguity #31
(ForwardDiff.Dual{T})(value) where T @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:69
(::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} @ Base char.jl:50

Possible fix, define
  (ForwardDiff.Dual{T})(::AbstractChar) where T

Ambiguity #32
(ForwardDiff.Dual{T, V})(x) where {T, V} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:79
(::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} @ Base char.jl:50

Possible fix, define
  (ForwardDiff.Dual{T, V})(::AbstractChar) where {T, V}

Ambiguity #40
^(x::Irrational, y::ForwardDiff.Dual{Ty}) where Ty @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
^(::Irrational{:ℯ}, x::Number) @ Base.MathConstants mathconstants.jl:119

Possible fix, define
  ^(::Irrational{:ℯ}, ::ForwardDiff.Dual{Ty}) where Ty

Ambiguity #43
^(x::Real, y::ForwardDiff.Dual{Ty}) where Ty @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
^(::Irrational{:ℯ}, x::Number) @ Base.MathConstants mathconstants.jl:119

Possible fix, define
  ^(::Irrational{:ℯ}, ::ForwardDiff.Dual{Ty}) where Ty

Ambiguity #55
convert(::Type{ForwardDiff.Dual{T, V, N}}, x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:435
convert(::Type{T}, index::CartesianIndex{1}) where T<:Number @ Base.IteratorsMD multidimensional.jl:135

Possible fix, define
  convert(::Type{ForwardDiff.Dual{T, V, N}}, ::CartesianIndex{1}) where {T, V, N}

Ambiguity #56
convert(::Type{ForwardDiff.Dual{T, V, N}}, x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:435
convert(::Type{T}, x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:271

Possible fix, define
  convert(::Type{ForwardDiff.Dual{T, V, N}}, ::Base.TwicePrecision) where {T, V, N}

Ambiguity #59
convert(::Type{ForwardDiff.Dual{T, V, N}}, x) where {T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:435
convert(::Type{T}, x::AbstractChar) where T<:Number @ Base char.jl:185

Possible fix, define
  convert(::Type{ForwardDiff.Dual{T, V, N}}, ::AbstractChar) where {T, V, N}

Ambiguity #80
log(x::Irrational, y::ForwardDiff.Dual{Ty}) where Ty @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
log(::Irrational{:ℯ}, x::Number) @ Base.MathConstants mathconstants.jl:124

Possible fix, define
  log(::Irrational{:ℯ}, ::ForwardDiff.Dual{Ty}) where Ty

Ambiguity #81
log(x::Real, y::ForwardDiff.Dual{Ty}) where Ty @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
log(::Irrational{:ℯ}, x::Number) @ Base.MathConstants mathconstants.jl:124

Possible fix, define
  log(::Irrational{:ℯ}, ::ForwardDiff.Dual{Ty}) where Ty

Ambiguity #90
promote_rule(::Type{R}, ::Type{ForwardDiff.Dual{T, V, N}}) where {R<:Real, T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:427
promote_rule(::Type{<:AbstractIrrational}, ::Type{T}) where T<:Real @ Base irrationals.jl:44

Possible fix, define
  promote_rule(::Type{R}, ::Type{ForwardDiff.Dual{T, V, N}}) where {T, V, N, R<:AbstractIrrational}

Ambiguity #92
promote_rule(::Type{R}, ::Type{ForwardDiff.Dual{T, V, N}}) where {R<:Real, T, V, N} @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:427
promote_rule(::Type{S}, ::Type{T}) where {S<:AbstractIrrational, T<:Number} @ Base irrationals.jl:45

Possible fix, define
  promote_rule(::Type{S}, ::Type{ForwardDiff.Dual{T, V, N}}) where {S<:AbstractIrrational, T, V, N}


I would appreciate your attention to this issue.

prbzrg avatar Dec 27 '23 17:12 prbzrg

Possible duplicate of https://github.com/JuliaDiff/ForwardDiff.jl/issues/597

jonschumacher avatar Jan 01 '24 21:01 jonschumacher

There are differences between Julia v1.9 and v1.10 ambiguity report. IMO, there should be an Aqua test in CI, so we can have an updated list of ambiguities for both Julia versions.

prbzrg avatar Jan 01 '24 21:01 prbzrg

x-ref: https://github.com/JuliaDiff/ForwardDiff.jl/pull/662

hyrodium avatar Jan 02 '24 04:01 hyrodium