Skip to content
Open
Show file tree
Hide file tree
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/structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function get_structure(forced_inners::Vector{Symbol}, nodes...)
allinds = setdiff(outers, intersect(outers, inners))

# now, map these indices to consecutive integers
idx_to_int = [idx => idxnum for (idxnum, idx) in enumerate(allinds)]
idx_to_int = Dict(idx => idxnum for (idxnum, idx) in enumerate(allinds))

#=
initialize some Dicts that will be useful for working with factors:
Expand All @@ -59,9 +59,9 @@ function get_structure(forced_inners::Vector{Symbol}, nodes...)
- ints_within_node: map node symbol to the subset of *all* its indices
corresponding to the fully outer indices
=#
idxdict = Dict{Symbol, Vector{Int}}([(idx => []) for idx in allinds])
inds_in_factor = Dict{Symbol, Vector{Int}}([(n.name => []) for n in nodes])
inds_in_node = Dict{Symbol, Vector{Int}}([(n.name => []) for n in nodes])
idxdict = Dict{Symbol, Vector{Int}}(idx => [] for idx in allinds)
inds_in_factor = Dict{Symbol, Vector{Int}}(n.name => [] for n in nodes)
inds_in_node = Dict{Symbol, Vector{Int}}(n.name => [] for n in nodes)

# now loop over nodes, building these dicts
for n in nodes
Expand Down Expand Up @@ -141,7 +141,7 @@ ndims(n::Node) = length(size(n))
getindex(n::Node, inds...) = n.data[inds...]

function getindex(n::ExprNode, inds...)
nd = Dict([(s => project(s, n, inds)) for (s, _) in n.nodedict])
nd = Dict(s => project(s, n, inds) for (s, _) in n.nodedict)
ExprDist{Val{n.name}}(nd)
end
setindex!(n::Node, val, inds...) = setindex!(n.data, val, inds...)
Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function ExprNode(name::Symbol, ex::Expr, nodelist::Vector{Node})
explicit_inners = collect(get_all_inds(ex))
stripped_ex = strip_inds(ex)
fi = get_structure(explicit_inners, nodelist...)
nodedict = Dict([n.name => n for n in nodelist])
nodedict = Dict(n.name => n for n in nodelist)
inners = union([n.innerinds for n in nodelist]...)
outers = union([n.outerinds for n in nodelist]...)
allinds = union(inners, outers)
Expand Down