Skip to content

cannot copy! SparseVectors #30443

Closed
Closed
@abraunst

Description

@abraunst
1.1.0-DEV.841> x=spzeros(1); copy!(x, spzeros(1));
ERROR: MethodError: no method matching empty!(::SparseVector{Float64,Int64})
Closest candidates are:
  empty!(::Base64.Buffer) at /home/ab/src/julia/build1.0/usr/share/julia/stdlib/v1.1/Base64/src/buffer.jl:15
  empty!(::BitSet) at bitset.jl:303
  empty!(::BitArray{1}) at bitarray.jl:1037
  ...
Stacktrace:
 [1] copy!(::SparseVector{Float64,Int64}, ::SparseVector{Float64,Int64}) at ./abstractarray.jl:655
 [2] top-level scope at none:0

it works for SparseMatrixCSC by the way. I don't know what is the "proper" way to fix this. I suspect that just implementing empty!(x::SparseVector) would lead to a suboptimal copy!(dst::SparseVector, src::SparseVector) with possibly redundant reallocations. So I'll leave this to someone more knowledgeable...

Metadata

Metadata

Assignees

No one assigned

    Labels

    sparseSparse arrays

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions