Skip to content
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

cannot copy! SparseVectors #30443

Closed
abraunst opened this issue Dec 18, 2018 · 0 comments
Closed

cannot copy! SparseVectors #30443

abraunst opened this issue Dec 18, 2018 · 0 comments
Labels
sparse Sparse arrays

Comments

@abraunst
Copy link
Contributor

abraunst commented Dec 18, 2018

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...

@ViralBShah ViralBShah added the sparse Sparse arrays label Dec 22, 2018
abraunst added a commit to abraunst/julia that referenced this issue Dec 29, 2018
andreasnoack pushed a commit that referenced this issue Jan 2, 2019
* implements copy!(dst::SparseVector, src) (fixes #30443)

* Adjust error message

* more efficient copy!

* fix typo

* fix return value

* add an assert and an explicit return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

2 participants