diff --git a/Project.toml b/Project.toml index 5c59413..63ba3bf 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ BangBang = "0.3.24" Compat = "2.2, 3" InitialValues = "0.2.6" OnlineStats = "1" -Transducers = "0.4.35" +Transducers = "0.4.39" julia = "1" [extras] diff --git a/src/LazyGroupBy.jl b/src/LazyGroupBy.jl index e0ffaa4..ea45e64 100644 --- a/src/LazyGroupBy.jl +++ b/src/LazyGroupBy.jl @@ -90,7 +90,7 @@ _groupby_kwargs(; init = Transducers.DefaultInit, kwargs...) = ((init,), kwargs) function _impl_fold(fold, kwargs, rf, xf, group) (init,), kwargs = _groupby_kwargs(; kwargs...) prexf, collection = extract_transducer(group.collection) - gxf = prexf |> GroupBy(group.key, Map(last) |> xf, rf, init) + gxf = opcompose(prexf, GroupBy(group.key, opcompose(Map(last), xf), rf, init)) d = fold(right, gxf, collection; init = nothing, kwargs...) if d === nothing error("input collection is empty or all filtered out") @@ -115,7 +115,7 @@ impl(::typeof(dreduce), kwargs, rf, xs) = impl(dreduce, kwargs, rf, Map(identity impl(::typeof(collect), kwargs, xf::Transducer, group::GroupedBy) = foldl( right, - GroupBy(group.key, Map(last) |> xf |> Map(SingletonVector), append!!), + GroupBy(group.key, opcompose(Map(last), xf, Map(SingletonVector)), append!!), group.collection, ) impl(::typeof(collect), kwargs, group::GroupedBy) = @@ -123,7 +123,7 @@ impl(::typeof(collect), kwargs, group::GroupedBy) = impl(::typeof(tcollect), kwargs, xf::Transducer, group::GroupedBy) = reduce( right, - GroupBy(group.key, Map(last) |> xf |> Map(SingletonVector), append!!), + GroupBy(group.key, opcompose(Map(last), xf, Map(SingletonVector)), append!!), group.collection, ) impl(::typeof(tcollect), kwargs, group::GroupedBy) = @@ -131,7 +131,7 @@ impl(::typeof(tcollect), kwargs, group::GroupedBy) = impl(::typeof(dcollect), kwargs, xf::Transducer, group::GroupedBy) = dreduce( right, - GroupBy(group.key, Map(last) |> xf |> Map(SingletonVector), append!!), + GroupBy(group.key, opcompose(Map(last), xf, Map(SingletonVector)), append!!), group.collection; kwargs..., ) @@ -223,7 +223,10 @@ impl(::typeof(findfirst), ::NamedTuple{()}, f, group::GroupedBy) = foldl( right, GroupBy( group.key ∘ last, - Filter(((_key, (_idx, val)),) -> f(val)) |> Map(((_key, (idx, _val)),) -> idx), + opcompose( + Filter(((_key, (_idx, val)),) -> f(val)), + Map(((_key, (idx, _val)),) -> idx), + ), left, ), pairs(group.collection), @@ -235,7 +238,7 @@ impl(::typeof(findlast), ::NamedTuple{()}, f, group::GroupedBy) = foldl( right, GroupBy( group.key ∘ last, - Filter(((_key, (_idx, val)),) -> f(val)) |> Map(((_key, (idx, _val)),) -> idx), + opcompose(Filter(((_key, (_idx, val)),) -> f(val)), Map(((_key, (idx, _val)),) -> idx)), right, ), pairs(group.collection), @@ -245,8 +248,10 @@ impl(::typeof(findall), kwargs, f, group::GroupedBy) = foldl( right, GroupBy( group.key ∘ last, - Filter(((_key, (_idx, val)),) -> f(val)) |> - Map(((_key, (idx, _val)),) -> SingletonVector(idx)), + opcompose( + Filter(((_key, (_idx, val)),) -> f(val)), + Map(((_key, (idx, _val)),) -> SingletonVector(idx)), + ), append!!, ), pairs(group.collection), diff --git a/test/environments/main/Manifest.toml b/test/environments/main/Manifest.toml index f443c3a..1fde043 100644 --- a/test/environments/main/Manifest.toml +++ b/test/environments/main/Manifest.toml @@ -28,6 +28,11 @@ git-tree-sha1 = "a6a8197ae253f2c1a22b2ae17c2dfaf5812c03aa" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" version = "3.13.0" +[[CompositionsBase]] +git-tree-sha1 = "f3955eb38944e5dd0fabf8ca1e267d94941d34a5" +uuid = "a33af91c-f02d-484b-be07-31d278c5ca2b" +version = "0.1.0" + [[ConstructionBase]] git-tree-sha1 = "a2a6a5fea4d6f730ec4c18a76d27ec10e8ec1c50" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" @@ -256,12 +261,12 @@ deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[Transducers]] -deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield", "SplittablesBase", "Tables"] -git-tree-sha1 = "3ffdba968ea18a106c7084283d58ee022297c9ce" +deps = ["ArgCheck", "BangBang", "CompositionsBase", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield", "SplittablesBase", "Tables"] +git-tree-sha1 = "329e69f3104057ae0aaab823c447bd7d5aae1d8b" repo-rev = "master" repo-url = "https://github.com/JuliaFolds/Transducers.jl.git" uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999" -version = "0.4.37-DEV" +version = "0.4.39" [[UUIDs]] deps = ["Random", "SHA"]