Skip to content

Push single values to a multidimensional array? #4

@robsmith11

Description

@robsmith11

Thanks for sharing this package. It's a very useful data structure to use when I write simulations and need moving windows of multidimensional data.

I was surprised by the behavior of push! at first:

julia> a = CircularArrayBuffer(zeros(4,3))
4×3 CircularArrayBuffer{Float64, 2}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0

julia> push!(a, 0.5)
4×3 CircularArrayBuffer{Float64, 2}:
 0.0  0.0  0.5
 0.0  0.0  0.5
 0.0  0.0  0.5
 0.0  0.0  0.5

On second thought, it of course makes sense that this behavior is useful in some situations, but would it also be possible and make sense to add another function or add an option to push! that would allow one to efficiently push single values?

Something like:

julia> push!(a, 0.5, broadcast=false)
4×3 CircularArrayBuffer{Float64, 2}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions