Skip to content

Commit d6bcb5a

Browse files
mkborregaardmbauman
authored andcommitted
Fallback for copying views into sparse matrices (#30895)
* Fallback for copying views into sparse matrices * SparseArray --> SparseVecOrMat * move copy method to sparsevector * use the union explicitly
1 parent 0b0a394 commit d6bcb5a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/SparseArrays/src/sparsevector.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ function getindex(A::SparseMatrixCSC{Tv,Ti}, I::AbstractVector) where {Tv,Ti}
700700
SparseVector(n, rowvalB, nzvalB)
701701
end
702702

703+
Base.copy(a::SubArray{<:Any,<:Any,<:Union{SparseVector, SparseMatrixCSC}}) = a.parent[a.indices...]
704+
703705
function findall(x::SparseVector)
704706
return findall(identity, x)
705707
end

0 commit comments

Comments
 (0)