You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mutable struct SobolPayload
params::Union{OrderedDict{Symbol, <:Any}, Nothing}
calc_second_order::Bool
N::Int
function SobolPayload(;params= nothing, calc_second_order = false, N = 1000)
return new(params, calc_second_order, N)
end
end
The params attribute of SobolPayload above should be parameterized as `Union{OrderedDict{Symbol, <:Distribution}, Nothing}, however this causes an error because params dictionaries such as
lrennels
changed the title
Parameterize SobolPayload.params as ::Union{OrderedDict{Symbol, <:Distribution}, Nothing
Parameterize SobolPayload.params with <: DIstiribution
Jan 25, 2019
It's because the most specific type that all the elements are a subtype of is the parameterized Distribution{Univariate,Continuous}.
If we define, say, EmpiricalDist as a univariate, discrete Distribution, e.g.,
struct EmpiricalDist <: Distribution{Univariate, Discrete}
foo::Int
end
we get:
Dict(:a => EmpiricalDistribution1(1), :b => Normal(1, 0.2))
Dict{Symbol,Distribution{Univariate,S} where S<:ValueSupport} with 2 entries:
:a => EmpiricalDistribution1(foo=1)
:b => Normal{Float64}(μ=1.0, σ=0.2)
This is a general issue in Julia: since it types a container based on the tightest type that contains all the contents, if your initial values aren't as general as the full set the container will hold, you have to type it explicitly, or the later additions (that fall outside the narrow type) will fail.
The
params
attribute ofSobolPayload
above should be parameterized as `Union{OrderedDict{Symbol, <:Distribution}, Nothing}, however this causes an error because params dictionaries such asseem to have type
OrderedDict{Symbol, Any}
, causing an error.The text was updated successfully, but these errors were encountered: