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

_from_array impl for vector doesn't handle nested elements #515

Open
sritchie opened this issue Nov 7, 2023 · 2 comments
Open

_from_array impl for vector doesn't handle nested elements #515

sritchie opened this issue Nov 7, 2023 · 2 comments

Comments

@sritchie
Copy link

sritchie commented Nov 7, 2023

For example, we can fill a nested choicemap from an array:

julia> Gen._from_array(Gen.choicemap(:face => Gen.choicemap(:cake => 2), :foo => 3), [4, 5], 1)
(2, DynamicChoiceMap(Dict{Any, Any}(:face => DynamicChoiceMap(Dict{Any, Any}(:cake => 4), Dict{Any, Any}()), :foo => 5), Dict{Any, Any}()))

but the implementation of _from_array for vectors doesn't recursively call _from_array on its elements:

julia> Gen._from_array([1,2,[3]], [4,5,6], 1)
ERROR: MethodError: no method matching _from_array(::Vector{Any}, ::Vector{Int64}, ::Int64)
@ztangent
Copy link
Member

ztangent commented Nov 7, 2023

Is there a reason why we need this implementation? (It's actually not clear to me where Gen._from_array(::Vector, ::Vector, ::Type) is even used elsewhere in the code.)

@sritchie
Copy link
Author

sritchie commented Nov 7, 2023

@ztangent maybe not and it might be worth removing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants