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

SplitBy followed by another SplitBy? #549

Open
tk3369 opened this issue Dec 26, 2022 · 2 comments
Open

SplitBy followed by another SplitBy? #549

tk3369 opened this issue Dec 26, 2022 · 2 comments

Comments

@tk3369
Copy link

tk3369 commented Dec 26, 2022

I'm not able to using SplitBy after another SplitBy without using collect in between. I just want to know if this is by design?

julia> xs = [1, 2, 3, 0, 1, 2, 3, 4, 0, 0, 1, 2, 5];  # input

julia> xs |> SplitBy(iszero) |> collect
3-element Vector{SubArray{Int64, 1, Vector{Int64}, Tuple{UnitRange{Int64}}, true}}:
 [1, 2, 3]
 [1, 2, 3, 4]
 [1, 2, 5]

julia> xs |> SplitBy(iszero) |> SplitBy(==(2))
ERROR: MethodError: no method matching keys(::Transducers.Eduction{Transducers.Reduction{Transducers.ReduceSplitBy{Transducers.var"#91#92"{SplitBy{typeof(iszero), Val{false}, Val{false}}, Vector{Int64}}, Transducers.SplitByReducingFunction{Val{false}, Val{false}}, Nothing}, Transducers.Reduction{NotA{Nothing}, Transducers.Reduction{Map{Transducers.var"#view_any#93"{Vector{Int64}}}, Transducers.BottomRF{Completing{typeof(push!!)}}}}}, Base.OneTo{Int64}})
Closest candidates are:
  keys(::Union{Tables.AbstractColumns, Tables.AbstractRow}) at ~/.julia/packages/Tables/T7rHm/src/Tables.jl:189
  keys(::Base.Generator) at generator.jl:54
  keys(::OrderedCollections.OrderedSet) at ~/.julia/packages/OrderedCollections/PRayh/src/ordered_set.jl:95
  ...
Stacktrace:
 [1] eachindex(itrs::Transducers.Eduction{Transducers.Reduction{Transducers.ReduceSplitBy{Transducers.var"#91#92"{SplitBy{typeof(iszero), Val{false}, Val{false}}, Vector{Int64}}, Transducers.SplitByReducingFunction{Val{false}, Val{false}}, Nothing}, Transducers.Reduction{NotA{Nothing}, Transducers.Reduction{Map{Transducers.var"#view_any#93"{Vector{Int64}}}, Transducers.BottomRF{Completing{typeof(push!!)}}}}}, Base.OneTo{Int64}})
   @ Base ./abstractarray.jl:282
 [2] |>(x::Transducers.Eduction{Transducers.Reduction{Transducers.ReduceSplitBy{Transducers.var"#91#92"{SplitBy{typeof(iszero), Val{false}, Val{false}}, Vector{Int64}}, Transducers.SplitByReducingFunction{Val{false}, Val{false}}, Nothing}, Transducers.Reduction{NotA{Nothing}, Transducers.Reduction{Map{Transducers.var"#view_any#93"{Vector{Int64}}}, Transducers.BottomRF{Completing{typeof(push!!)}}}}}, Base.OneTo{Int64}}, f::typeof(eachindex))
   @ Base ./operators.jl:911
 [3] (::SplitBy{Base.Fix2{typeof(==), Int64}, Val{false}, Val{false}})(xs::Transducers.Eduction{Transducers.Reduction{Transducers.ReduceSplitBy{Transducers.var"#91#92"{SplitBy{typeof(iszero), Val{false}, Val{false}}, Vector{Int64}}, Transducers.SplitByReducingFunction{Val{false}, Val{false}}, Nothing}, Transducers.Reduction{NotA{Nothing}, Transducers.Reduction{Map{Transducers.var"#view_any#93"{Vector{Int64}}}, Transducers.BottomRF{Completing{typeof(push!!)}}}}}, Base.OneTo{Int64}})
   @ Transducers ~/.julia/packages/Transducers/iubDU/src/splitby.jl:267
 [4] |>(x::Transducers.Eduction{Transducers.Reduction{Transducers.ReduceSplitBy{Transducers.var"#91#92"{SplitBy{typeof(iszero), Val{false}, Val{false}}, Vector{Int64}}, Transducers.SplitByReducingFunction{Val{false}, Val{false}}, Nothing}, Transducers.Reduction{NotA{Nothing}, Transducers.Reduction{Map{Transducers.var"#view_any#93"{Vector{Int64}}}, Transducers.BottomRF{Completing{typeof(push!!)}}}}}, Base.OneTo{Int64}}, f::SplitBy{Base.Fix2{typeof(==), Int64}, Val{false}, Val{false}})
   @ Base ./operators.jl:911
 [5] top-level scope
   @ REPL[120]:1
@MasonProtter
Copy link
Member

Seems like a bug, probably a missing method somewhere, I'll try to look into it soon.

@rickbeeloo
Copy link

@MasonProtter isn't this because the second SplitBy would actually receive the subarray, not the individual elements? Is @tkf not working on this any more?

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

3 participants