Skip to content

Commit

Permalink
Sparse: Fixup similar, remove broken test?
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Mar 23, 2015
1 parent d17b571 commit 7ebd38d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 5 additions & 3 deletions base/sparse/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ end
copy(S::SparseMatrixCSC) =
SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), copy(S.nzval))

similar(S::SparseMatrixCSC, Tv::Type, d::()) = spzeros(Tv, 1, 1)
similar(S::SparseMatrixCSC, Tv::Type, d::(Integer,)) = spzeros(Tv, d[1], 1)
similar(S::SparseMatrixCSC, Tv::Type, d::(Integer, Integer)) = spzeros(Tv, d[1], d[2])
similar(S::SparseMatrixCSC, Tv::Type, d::(Integer...)) = error("cannot construct sparse array with $(length(d)) dimensions")
similar(S::SparseMatrixCSC, Tv::NonTupleType=eltype(S)) = SparseMatrixCSC(S.m, S.n, copy(S.colptr), copy(S.rowval), Array(Tv, length(S.nzval)))
similar{Tv,Ti,TvNew}(S::SparseMatrixCSC{Tv,Ti}, ::Type{TvNew}, ::Type{Ti}) = similar(S, TvNew)
similar{Tv,Ti,TvNew,TiNew}(S::SparseMatrixCSC{Tv,Ti}, ::Type{TvNew}, ::Type{TiNew}) = SparseMatrixCSC(S.m, S.n, convert(Array{TiNew},S.colptr), convert(Array{TiNew}, S.rowval), Array(TvNew, length(S.nzval)))
similar{Tv}(S::SparseMatrixCSC, ::Type{Tv}, d::NTuple{Integer}) = spzeros(Tv, d...)
similar{Tv,Ti}(S::SparseMatrixCSC{Tv,Ti}, TvNew::Type, TiNew::Type) = SparseMatrixCSC(S.m, S.n, convert(Array{TiNew},S.colptr), convert(Array{TiNew}, S.rowval), Array(TvNew, length(S.nzval)))

function convert{Tv,Ti,TvS,TiS}(::Type{SparseMatrixCSC{Tv,Ti}}, S::SparseMatrixCSC{TvS,TiS})
if Tv == TvS && Ti == TiS
Expand Down
5 changes: 0 additions & 5 deletions test/sparsedir/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,6 @@ a = SparseMatrixCSC(2, 2, [1, 3, 5], [1, 2, 1, 2], [1.0, 0.0, 0.0, 1.0])
@test_approx_eq lufact(a)\[2.0, 3.0] [2.0, 3.0]
@test_approx_eq cholfact(a)\[2.0, 3.0] [2.0, 3.0]

# issue #10113
let S = spzeros(5,1), I = [false,true,false,true,false]
@test_throws BoundsError S[I]
end

# issue #9917
@test sparse([]') == reshape(sparse([]), 1, 0)

Expand Down

0 comments on commit 7ebd38d

Please sign in to comment.