JuliaFolds / Transducers.jl

Efficient transducers for Julia
https://juliafolds.github.io/Transducers.jl/dev/
MIT License
432 stars 24 forks source link

`GroupBy` does not call `complete` #337

Open tkf opened 4 years ago

tkf commented 4 years ago
julia> using LazyGroupBy

julia> using DataTools

julia> foldl.(averaging, grouped(isodd, 1:7))
Transducers.GroupByViewDict{Bool,DataTools.AverageState{Int64},…} with 2 entries:
  false => AverageState{Int64}(12, 3)
  true  => AverageState{Int64}(16, 4)

If Transducers.complete were called, it'd be something like

julia> pairs(ans) |> Map(modifying(second = x -> Transducers.complete(DataTools.merge_state, x))) |> x -> copy(Dict, x)
Dict{Bool,Float64} with 2 entries:
  false => 4.0
  true  => 4.0