Skip to content

Commit

Permalink
Provide Base.IteratorEltype() / Base.eltype()
Browse files Browse the repository at this point in the history
```
julia> euclidean(a, b)
ERROR: MethodError: no method matching oneunit(::Type{Any})

Closest candidates are:
  oneunit(::Type{Union{Missing, T}}) where T
   @ Base missing.jl:105
  oneunit(::Type{T}) where T
   @ Base number.jl:370
  oneunit(::T) where T
   @ Base number.jl:369
  ...

Stacktrace:
 [1] oneunit(#unused#::Type{Any})
   @ Base ./missing.jl:106
 [2] _eval_start(d::Euclidean, #unused#::Type{Any}, #unused#::Type{Any}, #unused#::Nothing)
   @ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:320
 [3] _eval_start(d::Euclidean, #unused#::Type{Any}, #unused#::Type{Any})
   @ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:318
 [4] eval_start(d::Euclidean, a::VariableRef, b::VariableRef)
   @ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:317
 [5] _evaluate(d::Euclidean, a::VariableRef, b::VariableRef, #unused#::Nothing)
   @ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:236
 [6] (::Euclidean)(a::VariableRef, b::VariableRef)
   @ Distances ~/.julia/packages/Distances/PvoXa/src/metrics.jl:328
 [7] top-level scope
   @ REPL[10]:1

```
  • Loading branch information
LebedevRI committed Nov 26, 2023
1 parent f47ce1e commit 705ae68
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,9 @@ function owner_model end
Base.ndims(::Type{<:AbstractJuMPScalar}) = 0
Base.ndims(::AbstractJuMPScalar) = 0

Base.IteratorEltype(::Type{<:AbstractJuMPScalar}) = Base.HasEltype()
Base.eltype(::Type{T}) where {T<:AbstractJuMPScalar} = T

# These are required to create symmetric containers of AbstractJuMPScalars.
LinearAlgebra.symmetric_type(::Type{T}) where {T<:AbstractJuMPScalar} = T
LinearAlgebra.hermitian_type(::Type{T}) where {T<:AbstractJuMPScalar} = T
Expand Down

0 comments on commit 705ae68

Please sign in to comment.