From 079797c8dbdbe082ccdbcc4d287648fed4b97d68 Mon Sep 17 00:00:00 2001 From: odow Date: Mon, 6 Jan 2025 14:28:17 +1300 Subject: [PATCH 1/2] [Utilities] add fallbacks for scalar_type and vector_type --- src/Utilities/functions.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utilities/functions.jl b/src/Utilities/functions.jl index 2d558f92e4..e713408873 100644 --- a/src/Utilities/functions.jl +++ b/src/Utilities/functions.jl @@ -592,7 +592,7 @@ end Type of functions obtained by indexing objects obtained by calling `eachscalar` on functions of type `F`. """ -function scalar_type end +scalar_type(::Type{F}) where {F} = Any # A default fallback scalar_type(::Type{<:AbstractVector{T}}) where {T} = T @@ -614,7 +614,7 @@ scalar_type(::Type{MOI.VectorNonlinearFunction}) = MOI.ScalarNonlinearFunction Return the [`MOI.AbstractVectorFunction`](@ref) associated with the scalar type `F`. """ -function vector_type end +vector_type(::Type{F}) where {F} = Any # A default fallback vector_type(::Type{T}) where {T} = Vector{T} From c9e9789c5797d235d2a113b450fe5d54ec6f5098 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Mon, 6 Jan 2025 14:46:07 +1300 Subject: [PATCH 2/2] Update functions.jl --- src/Utilities/functions.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utilities/functions.jl b/src/Utilities/functions.jl index e713408873..a87c3a8d9b 100644 --- a/src/Utilities/functions.jl +++ b/src/Utilities/functions.jl @@ -592,7 +592,7 @@ end Type of functions obtained by indexing objects obtained by calling `eachscalar` on functions of type `F`. """ -scalar_type(::Type{F}) where {F} = Any # A default fallback +scalar_type(::Type{<:MOI.AbstractVectorFunction}) = Any # A default fallback scalar_type(::Type{<:AbstractVector{T}}) where {T} = T @@ -614,7 +614,7 @@ scalar_type(::Type{MOI.VectorNonlinearFunction}) = MOI.ScalarNonlinearFunction Return the [`MOI.AbstractVectorFunction`](@ref) associated with the scalar type `F`. """ -vector_type(::Type{F}) where {F} = Any # A default fallback +function vector_type end vector_type(::Type{T}) where {T} = Vector{T}