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
A dict of type, say, {Symbol, Any} such as Dict{Symbol, Any}(:a => collect(1:10), :b => true) will be turned into a Vector{Dict{Symbol, Integer}}. This can create unwanted behavior.
I propose the following modification to _dict_list:
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))
vec(
map(Iterators.product(values(iterable_dict)...)) do vals
dd = [k=>convert(eltype(c[k]),v) for (k,v) in zip(keys(iterable_dict),vals)]
if isempty(non_iterable_dict)
Dict(dd)
elseif isempty(iterable_dict)
non_iterable_dict
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)...)
end
end
)
end
The text was updated successfully, but these errors were encountered:
A dict of type, say,
{Symbol, Any}
such asDict{Symbol, Any}(:a => collect(1:10), :b => true)
will be turned into aVector{Dict{Symbol, Integer}}
. This can create unwanted behavior.I propose the following modification to
_dict_list
:The text was updated successfully, but these errors were encountered: