AbstractTrees.jl icon indicating copy to clipboard operation
AbstractTrees.jl copied to clipboard

Implement children(::AbstractDict) correctly

Open jlumpe opened this issue 3 years ago • 3 comments

Previously the children of an AbstractDict were pair objects, which made printing work but otherwise didn't make a lot of sense. Now that we have functional printing of child keys in print_tree this can be fixed.

children(dict::AbstractDict) now returns DictChildren(dict), which gives identical results for keys(), pairs(), and getindex() but behaves as a collection identical to values(dict). This can also be used for user types.

Currently some tests are not passing because it looks like the current tree traversal implementations expect children to return something with AbstractVector-type indices.

jlumpe avatar Sep 02 '21 19:09 jlumpe

@oscardssmith Any thoughts on this?

jlumpe avatar May 07 '22 01:05 jlumpe

I think this looks good. That said, it probably would be good to get input from @Keno also.

oscardssmith avatar May 11 '22 15:05 oscardssmith

I believe this doesn't make sense given https://github.com/JuliaCollections/AbstractTrees.jl/pull/96

oscardssmith avatar May 17 '22 01:05 oscardssmith