From 36accade0ca4c3161fe2dfcfb3024758df5efb9e Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Wed, 14 Aug 2024 15:34:38 +0100 Subject: [PATCH] Fix get() ambiguities Done by: 1. Constraining the type parameter to AbstractVector{Symbol} 2. Modifying the method below it to use a vector instead of a tuple --- src/optimisation/Optimisation.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/optimisation/Optimisation.jl b/src/optimisation/Optimisation.jl index e06989792..eecfcad22 100644 --- a/src/optimisation/Optimisation.jl +++ b/src/optimisation/Optimisation.jl @@ -277,13 +277,13 @@ StatsBase.loglikelihood(m::ModeResult) = m.lp """ Base.get(m::ModeResult, var_symbol::Symbol) - Base.get(m::ModeResult, var_symbols) + Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol}) Return the values of all the variables with the symbol(s) `var_symbol` in the mode result `m`. The return value is a `NamedTuple` with `var_symbols` as the key(s). The second -argument should be either a `Symbol` or an iterator of `Symbol`s. +argument should be either a `Symbol` or a vector of `Symbol`s. """ -function Base.get(m::ModeResult, var_symbols) +function Base.get(m::ModeResult, var_symbols::AbstractVector{Symbol}) log_density = m.f # Get all the variable names in the model. This is the same as the list of keys in # m.values, but they are more convenient to filter when they are VarNames rather than @@ -304,7 +304,7 @@ function Base.get(m::ModeResult, var_symbols) return (; zip(var_symbols, value_vectors)...) end -Base.get(m::ModeResult, var_symbol::Symbol) = get(m, (var_symbol,)) +Base.get(m::ModeResult, var_symbol::Symbol) = get(m, [var_symbol]) """ ModeResult(log_density::OptimLogDensity, solution::SciMLBase.OptimizationSolution)