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

dict_list changed type, fixed #342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"julia.environmentPath": "/Users/smerlak/Dropbox/github/DrWatson.jl"
}
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this file should be committed here.

9 changes: 6 additions & 3 deletions src/dict_list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,14 @@ function is_solution_subset_of_existing(trial, trial_solutions)
end

function _dict_list(c::AbstractDict)

dict = typeof(c)

iterable_fields = filter(k -> typeof(c[k]) <: Vector, keys(c))
non_iterables = setdiff(keys(c), iterable_fields)

iterable_dict = Dict(iterable_fields .=> getindex.(Ref(c), iterable_fields))
non_iterable_dict = Dict(non_iterables .=> getindex.(Ref(c), non_iterables))
iterable_dict = dict(iterable_fields .=> getindex.(Ref(c), iterable_fields))
non_iterable_dict = dict(non_iterables .=> getindex.(Ref(c), non_iterables))

vec(
map(Iterators.product(values(iterable_dict)...)) do vals
Expand All @@ -111,7 +114,7 @@ function _dict_list(c::AbstractDict)
else
# We can't use merge here because it promotes types.
# The uniqueness of the dictionary keys is guaranteed.
Dict(dd..., collect(non_iterable_dict)...)
dict(dd..., collect(non_iterable_dict)...)
end
end
)
Expand Down