Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getfield(Main, ...) #355

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/TOMLInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ function collect_from_expr(e::Expr, eltype::AbstractString; repeat::Bool = false

for i in 1:n_elem
elem = e.args[i]
arr[i] = getfield(Main, elem.args[1])(elem.args[2:end]...)
arr[i] = getfield(ParameterDistributions, elem.args[1])(elem.args[2:end]...)
end

return repeat ? arr[1] : arr

else
# There is a single distribution / constraint
return getfield(Main, e.args[1])(e.args[2:end]...)
return getfield(ParameterDistributions, e.args[1])(e.args[2:end]...)
end

end
Expand All @@ -234,15 +234,15 @@ function get_distribution_from_expr(d::Expr)
dist_type_symb = d.args[1]

if dist_type_symb == Symbol("Parameterized")
dist = getfield(Main, d.args[2].args[1])
dist = getfield(Distributions, d.args[2].args[1])
dist_args = d.args[2].args[2:end]
dist_type = getfield(Main, dist_type_symb)
dist_type = getfield(ParameterDistributions, dist_type_symb)

return dist_type(dist(dist_args...))

elseif dist_type_symb == Symbol("Samples")
dist_args = construct_2d_array(d.args[2])
dist_type = getfield(Main, dist_type_symb)
dist_type = getfield(ParameterDistributions, dist_type_symb)

return dist_type(dist_args)

Expand Down
Loading