Skip to content

Commit

Permalink
Test shape checks for sparse elementwise binary operations equivalent…
Browse files Browse the repository at this point in the history
… to map.
  • Loading branch information
Sacha0 committed Dec 18, 2016
1 parent 70c4b5d commit 6615e87
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/sparse/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ do33 = ones(3)
# check sparse binary op
@test all(Array(se33 + convert(SparseMatrixCSC{Float32,Int32}, se33)) == 2*eye(3))
@test all(Array(se33 * convert(SparseMatrixCSC{Float32,Int32}, se33)) == eye(3))
@testset "Shape checks for sparse elementwise binary operations equivalent to map" begin
sqrfloatmat, colfloatmat = sprand(4, 4, 0.5), sprand(4, 1, 0.5)
@test_throws DimensionMismatch (+)(sqrfloatmat, colfloatmat)
@test_throws DimensionMismatch (-)(sqrfloatmat, colfloatmat)
@test_throws DimensionMismatch min(sqrfloatmat, colfloatmat)
@test_throws DimensionMismatch max(sqrfloatmat, colfloatmat)
sqrboolmat, colboolmat = sprand(Bool, 4, 4, 0.5), sprand(Bool, 4, 1, 0.5)
@test_throws DimensionMismatch (&)(sqrboolmat, colboolmat)
@test_throws DimensionMismatch (|)(sqrboolmat, colboolmat)
@test_throws DimensionMismatch xor(sqrboolmat, colboolmat)
end

# check horiz concatenation
@test all([se33 se33] == sparse([1, 2, 3, 1, 2, 3], [1, 2, 3, 4, 5, 6], ones(6)))
Expand Down

0 comments on commit 6615e87

Please sign in to comment.