You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> cb = CircularBuffer(1)
> 0-element CircularBuffer{Any}
julia> filter(s -> s < 3, cb)
ERROR: TypeError: in typeassert, expected AbstractArray{Bool}, got a value of type Vector{Any}
Stacktrace:
[1] filter(f::var"#25#26", a::CircularBuffer{Any})
@ Base ./array.jl:2492
[2] top-level scope
@ REPL[27]:1
Specifying the eltype does not fix the issue
julia> cb = CircularBuffer{Integer}(1)
> 0-element CircularBuffer{Integer}
julia> filter(s -> s < 3, cb)
ERROR: TypeError: in typeassert, expected AbstractArray{Bool}, got a value of type Vector{Any}
Stacktrace:
[1] filter(f::var"#39#40", a::CircularBuffer{Integer})
@ Base ./array.jl:2492
[2] top-level scope
@ REPL[37]:1
Desired behaviour
It should behave the same way as with a Vector type.
julia> filter(s -> s < 3, [])
> Any[]
Possible solution
Since filter, returns a Vector type for CircularBuffer there are two solutions that both produce an ideologically different ouput:
Specify the filter method for CircularBuffer to use the method with Array on the underlining buffer and not AbstractArray on the struct,
Overwrite the filter method and make it return a new CircularBuffer.
I would think that the second option is the way to go since it would be easy for the user to use the method outputing Vector on demand.
Can you assign me?
The text was updated successfully, but these errors were encountered:
kunzaatko
changed the title
[bug] Type assert of filter fails for emtpy CircularBuffer
[bug] Type assert of filter fails for empty CircularBufferMay 8, 2022
Replicate
Specifying the eltype does not fix the issue
Desired behaviour
It should behave the same way as with a
Vector
type.Possible solution
Since filter, returns a
Vector
type forCircularBuffer
there are two solutions that both produce an ideologically different ouput:filter
method forCircularBuffer
to use the method withArray
on the underlining buffer and notAbstractArray
on the struct,filter
method and make it return a newCircularBuffer
.I would think that the second option is the way to go since it would be easy for the user to use the method outputing
Vector
on demand.Can you assign me?
The text was updated successfully, but these errors were encountered: