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

ScanEmit receives the wrong argument #556

Open
pepijndevos opened this issue May 24, 2023 · 0 comments
Open

ScanEmit receives the wrong argument #556

pepijndevos opened this issue May 24, 2023 · 0 comments

Comments

@pepijndevos
Copy link

Here is a reduced example of my code

using Transducers

s = zip(1:6, [0, 1, 0, 2, 1 ,2])

dx = Consecutive(2; step = 1) |> Map((((x1, y), (x2, _)),) -> (x2 - x1, y))
function test(a, b)
    @show a b
    (x, y) = b
    ((a, y), x+a)
end
ix = ScanEmit(test, 0.0)
squash = ReducePartitionBy(((dx, y),) -> y, Completing(((dx1, y1), (dx2, y2)) -> (dx1 + dx2, y2)), (0.0, NaN))

s |> dx |> squash |> collect |> ix |> collect
s |> dx |> squash|> ix |> collect

The case without the extra collect calls test with two floats

ERROR: BoundsError: attempt to access Float64 at index [2]
Stacktrace:
  [1] indexed_iterate(I::Float64, i::Int64, state::Nothing)
    @ Base ./tuple.jl:101
  [2] test(a::Float64, b::Float64)
    @ Main ~/code/CedarSim.jl/test/trans.jl:8
  [3] combine(rf::Transducers.Reduction{…}, a::Transducers.PrivateState{…}, b::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/library.jl:1324
  [4] complete(rf::Transducers.Reduction{…}, acc::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/partitionby.jl:107
  [5] complete(rf::Transducers.Reduction{…}, result::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/core.jl:548
  [6] complete(rf::Transducers.Reduction{…}, acc::Transducers.PrivateState{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/consecutive.jl:97
  [7] __foldl__
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:242 [inlined]
  [8] transduce(rf1::RF, init::Any, coll::Any; simd::Union{Val{true}, Val{false}, Val{:ivdep}, Bool, Symbol}) where RF<:Transducers.AbstractReduction
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:523 [inlined]
  [9] transduce(rf1::RF, init::Any, coll::Any) where RF<:Transducers.AbstractReduction
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:512 [inlined]
 [10] transduce(xform::Transducers.Composition{…}, f::Transducers.AdHocRF{…}, init::BangBang.SafeCollector{…}, coll::Base.Iterators.Zip{…}; kwargs::Base.Pairs{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:506
 [11] transduce(xform::Transducer, f::F, init::Any, coll::Any) where F
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:504 [inlined]
 [12] _collect(xf::Transducers.Composition{…}, coll::Base.Iterators.Zip{…}, ::Transducers.SizeChanging, ::Base.HasShape{…})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:810
 [13] collect(xf::Transducers.Composition{Consecutive{…}, Transducers.Composition{…}}, coll::Base.Iterators.Zip{Tuple{…}})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:806 [inlined]
 [14] collect(foldable::Transducers.Eduction{Transducers.Reduction{Consecutive{…}, Transducers.Reduction{…}}, Base.Iterators.Zip{Tuple{…}}})
    @ Transducers ~/.julia/packages/Transducers/IWhZW/src/processes.jl:807 [inlined]
 [15] |>(x::Transducers.Eduction{Transducers.Reduction{Consecutive{…}, Transducers.Reduction{…}}, Base.Iterators.Zip{Tuple{…}}}, f::typeof(collect))
    @ Base ./operators.jl:915
 [16] top-level scope
    @ ~/code/CedarSim.jl/test/trans.jl:15
Some type information was truncated. Use `show(err)` to see complete types.

I guess it's a problem with multiple stateful transducers getting combined incorrectly? No idea how that works exactly.

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