vexatos / circulararrays.jl Goto Github PK
View Code? Open in Web Editor NEWMulti-dimensional arrays with fixed size and circular indexing.
License: MIT License
Multi-dimensional arrays with fixed size and circular indexing.
License: MIT License
Could we have a deleteat!
for CircularVector
?
julia> using CircularArrays
julia> c = CircularVector([1,2,3])
3-element CircularVector(::Vector{Int64}):
1
2
3
julia> push!(c, 4)
ERROR: MethodError: no method matching resize!(::CircularVector{Int64, Vector{Int64}}, ::Int64)
Closest candidates are:
resize!(::Vector, ::Integer)
@ Base array.jl:1246
resize!(::BitVector, ::Integer)
@ Base bitarray.jl:814
resize!(::SparseArrays.ReadOnly, ::Any)
@ SparseArrays ~/.julia/juliaup/julia-1.9.3+0.x64.linux.gnu/share/julia/stdlib/v1.9/SparseArrays/src/readonly.jl:33
...
Stacktrace:
[1] _append!(a::CircularVector{Int64, Vector{Int64}}, #unused#::Base.HasLength, iter::Tuple{Int64})
@ Base ./array.jl:1134
[2] append!(a::CircularVector{Int64, Vector{Int64}}, iter::Tuple{Int64})
@ Base ./array.jl:1126
[3] push!(a::CircularVector{Int64, Vector{Int64}}, iter::Int64)
@ Base ./array.jl:1127
[4] top-level scope
@ REPL[6]:1
See #2 (comment) by @yha and JuliaArrays/OffsetArrays.jl#87. This needs to be solved, but there currently isn't any good way to do that. Would probably have to create a hard dependency on OffsetArrays until this is fixed in Base
, which is really ugly and I'd rather not do it.
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
I get an error when I try to use map on a circular array. It seems like this should work but perhaps I am missing something.
e.g. map(x -> x+1, CircularArray([1,2,3,4]))
throws an error...
ERROR: MethodError: similar(::CircularVector{Int64, Vector{Int64}}, ::Type{Int64}, ::Tuple{Base.OneTo{Int64}}) is ambiguous. Candidates: ..............
reduce seems to work which slightly surprised me given the above
reduce(+, CircularArray([1,2,3,4]))
10
The CircularVector
is missing a insert!
method that allows insertion at a specific index.
What I would appreciate is a way to construct a matrix that is circular in the first dimension while restricted in the other dimension (i.e. should be able to throw BoundsError
)
There are two ways to achieve this:
InfiniteArrays
). This is more straightforward on the surface but are prone to infinite loops at broadcast-like operations.checkbounds
needs to be overloaded.This package is a dependency in Meshes.jl and we recently started having issues with a non-working resize!
function. I think this is probably related to semantic versioning misunderstanding...
When you updated from 1.1 to 1.2 to 1.3 you adopted the following rule? https://semver.org/spec/v2.0.0.html#spec-item-7
Our tests are failing now downstream. Could you please double check and help fix the issues?
Also, I reiterate the importance of placing this package in an organization where multiple members can help maintain and double check these things before submitting disruptive new releases.
┌ CircularArrays [7a955b69-7140-5f4e-a0ed-f168c5e2e749]
│ WARNING: Wrapping `Vararg` directly in UnionAll is deprecated (wrap the tuple instead).
I am using this package in Meshes.jl to handle polygonal geometries that create loops. I wonder if you would be willing to migrate the package to the JuliaArrays organization for greater visibility and maintenance reasons? It is nice to have multiple people working on a fundamental package like this to make sure it is up-to-date and following all the latest tricks.
These all produce the same type: CircularArray{Float64, 2, Matrix{Float64}}
CircularArray( zeros(2, 2) )
CircularArray{Float64}( zeros(2, 2) )
CircularArray{Float64, 2}( zeros(2, 2) )
However, CircularArray{Float64, 2, Matrix{Float64}}( zeros(2, 2) )
fails with MethodError: no method matching CircularArray{Float64, 2, Matrix{Float64}}(::Matrix{Float64})
This is a problem when creating a function that takes an AbstractArray, produces a new Vector that gets reshape
d to the same size
as the AbstractArray, then tries to return the same type as the original AbstractArray using convert
, or by trying to call the constructor using typeof
or by the function being parametric.
I think the missing constructor can be addressed by adding a constructor that is parametric on all three types? I don't know if it makes sense to have convert
work in this context.
Operations on CircularArrays give usual Arrays instead:
julia> CircularArray(rand(3,3)) .+ 1
3×3 Matrix{Float64}:
1.59308 1.58855 1.67183
1.86402 1.33325 1.31673
1.15693 1.32027 1.24405
julia> using CircularArrays
julia> v = CircularVector([1,2,3])
3-element CircularVector(::Vector{Int64}):
1
2
3
julia> empty(v)
Int64[]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.