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

ERROR: Stateful transducer Enumerate(1, 1) does not support "combine" #561

Open
ParadaCarleton opened this issue Sep 13, 2023 · 0 comments

Comments

@ParadaCarleton
Copy link

A bit of a weird one:

julia> x = 1:100
1:100

julia> x |> foldxt(+)
5050

julia> x |> Enumerate() |> Map(last) |> foldxt(+)
ERROR: Stateful transducer Enumerate(1, 1) does not support `combine`
Stacktrace:
  [1] error(::String, ::Enumerate{Int64}, ::String)
    @ Base ./error.jl:44
  [2] combine(rf::Transducers.Reduction{…}, a::Transducers.PrivateState{…}, b::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/core.jl:580
  [3] _reduce(ctx::Transducers.NoopDACContext, rf::Transducers.Reduction{…}, init::Transducers.InitOf{…}, reducible::Transducers.SizedReducible{…})
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:160
  [4] _reduce(ctx::Transducers.NoopDACContext, rf::Transducers.Reduction{…}, init::Transducers.InitOf{…}, reducible::Transducers.SizedReducible{…}) (repeats 3 times)
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:155
  [5] _transduce_assoc_nocomplete
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:138 [inlined]
  [6] transduce_assoc(xform::Transducers.Composition{…}, step::Completing{…}, init::Transducers.InitOf{…}, coll0::UnitRange{…}; simd::Val{…}, basesize::Nothing, stoppable::Nothing, nestlevel::Nothing)
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:108
  [7] transduce_assoc
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:84 [inlined]
  [8] foldxt
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:242 [inlined]
  [9] foldxt
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:245 [inlined]
 [10] #188
    @ Transducers ~/.julia/packages/Transducers/xbs8O/src/reduce.jl:248 [inlined]
 [11] |>(x::Transducers.Eduction{Transducers.Reduction{…}, UnitRange{…}}, f::Transducers.var"#188#189"{@Kwargs{}, typeof(+)})
    @ Base ./operators.jl:915
 [12] top-level scope
    @ REPL[42]:1

So, first, why is Enumerate considered stateful even when used on an object that should let Enumerate be stateless (like an array)? Is there a simple way to get this behavior? If not, should there be some kind of transducer for accessing both the keys and values of an array/dictionary, like KeyVal, that is stateless?

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

1 participant