Skip to content

Commit 0435d90

Browse files
committed
add some small tests
1 parent 671d723 commit 0435d90

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/basic.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module BasicTests
2+
23
using SparseArrayKit
34
using Test, TestExtras, LinearAlgebra, Random
5+
using TupleTools
46

57
#=
68
generate a whole bunch of random contractions, compare with the dense result
@@ -96,4 +98,19 @@ end
9698
@test size(SparseArray(I, 3, 8)) == (3, 8)
9799
end
98100

101+
@timedtestset "Index manipulations" begin
102+
dims = (2, 3, 4)
103+
A = randn_sparse(Float64, dims)
104+
@test @constinferred(reindexdims(A, (2, 1, 3))) == permutedims(A, (2, 1, 3))
105+
106+
A_expanded = @constinferred reindexdims(A, (1, 1, 2, 3))
107+
@test size(A_expanded) == TupleTools.getindices(size(A), (1, 1, 2, 3))
108+
@test norm(A_expanded) norm(A)
109+
@test reindexdims(A_expanded, (1, 3, 4)) == A
110+
111+
A_reduced = @constinferred reindexdims(A, (1, 2))
112+
@test size(A_reduced) == TupleTools.getindices(size(A), (1, 2))
113+
@test Array(A_reduced) sum(Array(A); dims = 3)
114+
end
115+
99116
end

0 commit comments

Comments
 (0)