JeffreySarnoff/NamedTupleTools.jl

namedtuple(::Dict{Symbol}) crates a tuple of pairs instead of a NamedTuple

zsunberg opened this issue · 3 comments

This does not seem like the intended behavior:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.2.0 (2019-08-20)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(v1.2) pkg> add NamedTupleTools#master
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating registry at `~/.julia/registries/JuliaPOMDP`
  Updating git-repo `https://github.com/JuliaPOMDP/Registry`
   Cloning git-repo `https://github.com/JeffreySarnoff/NamedTupleTools.jl.git`
  Updating git-repo `https://github.com/JeffreySarnoff/NamedTupleTools.jl.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.2/Project.toml`
  [d9ec5142] ~ NamedTupleTools v0.10.0 ⇒ v0.10.0 #master (https://github.com/JeffreySarnoff/NamedTupleTools.jl.git)
  Updating `~/.julia/environments/v1.2/Manifest.toml`
  [d9ec5142] ~ NamedTupleTools v0.10.0 ⇒ v0.10.0 #master (https://github.com/JeffreySarnoff/NamedTupleTools.jl.git)

julia> using NamedTupleTools
[ Info: Recompiling stale cache file /home/zach/.julia/compiled/v1.2/NamedTupleTools/Xfy1D.ji for NamedTupleTools [d9ec5142-1e00-5aa0-9d6a-321866360f50]

julia> namedtuple(Dict(:a=>1))
(:a => 1,)

Should I try to make a PR to fix it?

Current workaround is d = Dict(:a=>1); namedtuple(keys(d)...)(values(d)...)

Good bug find. It fails for the case where the dictionary has a single entry. I will repair this promptly. I have additional edits to make to this today. Thank you.

fixed in current master, new version pending merge