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

Dev #161

Closed
wants to merge 3 commits into from
Closed

Dev #161

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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = [ "Peter Thestrup Waade [email protected]",
"Anna Hedvig Møller [email protected]",
"Jacopo Comoglio [email protected]",
"Christoph Mathys [email protected]"]
version = "0.5.4"
version = "0.5.5"


[deps]
Expand All @@ -13,7 +13,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[compat]
ActionModels = "0.5"
ActionModels = "0.6"
Distributions = "0.25"
RecipesBase = "1"
julia = "1.10"
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Documenter
using Literate


hgf_path = dirname(dirname(pathof(HierarchicalGaussianFiltering)))
hgf_path = dirname(pathof(HierarchicalGaussianFiltering))

juliafiles_path = hgf_path * "/docs/julia_files"
user_guides_path = juliafiles_path * "/user_guide"
Expand Down
File renamed without changes
File renamed without changes
30 changes: 9 additions & 21 deletions src/ActionModels_variations/utils/get_history.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,20 @@ end

function ActionModels.get_history(node::AbstractNode)

#Initialize dictionary
state_histories = Dict()

#Go through all states in the node's history
for state_key in fieldnames(typeof(node.history))
#Get the node's name and history
node_name = node.name
node_history = node.history

#And add their histories to the output
state_histories[String(state_key)] = getproperty(node.history, state_key)
#Return a dictionary of the node's history
Dict((node_name,string(key))=>getfield(node_history, key) for key ∈ fieldnames(typeof(node_history)))

end

return state_histories
end

function ActionModels.get_history(hgf::HGF)

#Initialize dict for state histories
state_histories = Dict()

#For each node
for node in hgf.ordered_nodes.all_nodes
#Get out the histories of the node
node_histories = get_history(node)
#And merge them with the dict
merge(state_histories, node_histories)
end
#Get the histories of all nodes
merge(
[get_history(node) for node in hgf.ordered_nodes.all_nodes]...
)

return state_histories
end
39 changes: 14 additions & 25 deletions src/ActionModels_variations/utils/get_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,38 +100,27 @@ function ActionModels.get_states(hgf::HGF, node_name::String)
throw(ArgumentError("The node $node_name does not exist"))
end

#Initialize dict
states = Dict()

#Get out the node
node = hgf.all_nodes[node_name]
#Get the states of the node
node = get_states(hgf.all_nodes[node_name])
end

#For each state in the node
for state_key in fieldnames(typeof(node.states))
function ActionModels.get_states(node::AbstractNode)

#Add it to the dictionary
states[(node_name, String(state_key))] = get_states(node, String(state_key))
#Get the node's name and states
node_name = node.name
node_states = node.states

end
#Return a dictionary of the node's states
Dict((node_name,string(key))=>getfield(node_states, key) for key ∈ fieldnames(typeof(node_states)))

#Get its states
return states
end


### For getting all states of an HGF ###
function ActionModels.get_states(hgf::HGF)

#Initialize dict for state states
states = Dict()

#For each node
for node_name in keys(hgf.all_nodes)
#Get out the states of the node
node_states = get_states(hgf, node_name)
#And merge them with the dict
states = merge(states, node_states)
end

return states
#Get the states of all nodes
merge(
[get_states(node) for node in hgf.ordered_nodes.all_nodes]...
)

end
Loading