-
Notifications
You must be signed in to change notification settings - Fork 124
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
[SparseArrayDOKs] [ENHANCEMENT] resize!
and @maybe_grow
#1433
Comments
I like this proposal & will try to work on it if I can figure out the macro part. Other name suggestions could be |
I like the terminology |
Some thought may be needed about constructors also, given this system. While the following works: m = SparseArrayDOK{Float64,2}((0, 0)) the default constructor errors: m = SparseArrayDOK{Float64,2}() # gives an error It's not clear to me whether it's best to require users to give an initial size if they are going to use the grow feature, and if they would give |
I think we should just follow the convention followed by other Julia AbstractArray constructors, which is that if no size is specified it constructs a zero-dimensional julia> Array{Float64}(undef)
0-dimensional Array{Float64, 0}:
2.225328024e-314
julia> zeros()
0-dimensional Array{Float64, 0}:
0.0
julia> Array{Float64,2}(undef)
ERROR: MethodError: no method matching Matrix{Float64}(::UndefInitializer)
Closest candidates are:
Matrix{T}(::UndefInitializer, ::Tuple{Int64, Int64}) where T
@ Core boot.jl:487
Matrix{T}(::UndefInitializer, ::Int64, ::Int64) where T
@ Core boot.jl:479
Array{T, N}(::UndefInitializer, ::Tuple{Vararg{Int64, N}}) where {T, N}
@ Core boot.jl:489
...
Stacktrace:
[1] top-level scope
@ REPL[4]:1 and users should be required to write |
It would be helpful to make the size of
SparseArrayDOK
a mutable field (and maybe define anIsResizable
trait).Then we can have an API for setting the size of a
SparseArrayDOK
in-place with:and additionally functionality for setting an element and allowing the array to grow as needed:
which could have an external API based around annotating calls to
setindex!
with a macro@maybe_grow
:@emstoudenmire
The text was updated successfully, but these errors were encountered: