Skip to content

Commit 265e267

Browse files
authored
Compare matrices in backend_testinfoperator (#328)
1 parent 91d94c2 commit 265e267

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

ApproxFunBaseTest/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ApproxFunBaseTest"
22
uuid = "a931bfaf-0cfd-4a5c-b69c-bf2eed002b43"
33
authors = ["Jishnu Bhattacharya <[email protected]>"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"

ApproxFunBaseTest/src/ApproxFunBaseTest.jl

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module ApproxFunBaseTest
22

3+
Base.Experimental.@optlevel 1
4+
35
using ApproxFunBase
46
using ApproxFunBase: plan_transform, plan_itransform, israggedbelow, RaggedMatrix, isbandedbelow, isbanded,
57
blockstart, blockstop, resizedata!
@@ -142,11 +144,18 @@ function backend_testinfoperator(A)
142144
@test isa(A[k,j],eltype(A))
143145
end
144146

145-
@test A[1:5,1:5][2:5,1:5] A[2:5,1:5]
146-
@test A[1:5,2:5] A[1:5,1:5][:,2:end]
147-
@test A[1:10,1:10][5:10,5:10] [A[k,j] for k=5:10,j=5:10]
148-
@test A[1:10,1:10][5:10,5:10] A[5:10,5:10]
149-
@test A[1:30,1:30][20:30,20:30] A[20:30,20:30]
147+
A10 = A[1:10,1:10]
148+
A10m = Matrix(A10)
149+
A10_510 = A10m[5:10,5:10]
150+
A30 = A[1:30,1:30]
151+
A30_2030 = A30[20:30,20:30]
152+
A30_2030m = Matrix(A30_2030)
153+
154+
@test Matrix(B[2:5,1:5]) Matrix(A[2:5,1:5])
155+
@test Matrix(A[1:5,2:5]) Matrix(B[:,2:end])
156+
@test A10_510 [A[k,j] for k=5:10,j=5:10]
157+
@test A10_510 Matrix(A[5:10,5:10])
158+
@test A30_2030m Matrix(A[20:30,20:30])
150159

151160
@test Matrix(A[Block(1):Block(3),Block(1):Block(3)]) Matrix(A[blockstart(rangespace(A),1):blockstop(rangespace(A),3),blockstart(domainspace(A),1):blockstop(domainspace(A),3)])
152161
@test Matrix(A[Block(3):Block(4),Block(2):Block(4)]) Matrix(A[blockstart(rangespace(A),3):blockstop(rangespace(A),4),blockstart(domainspace(A),2):blockstop(domainspace(A),4)])
@@ -157,29 +166,39 @@ function backend_testinfoperator(A)
157166
end
158167

159168
co=cache(A)
160-
@test co[1:10,1:10] A[1:10,1:10]
161-
@test co[1:10,1:10] A[1:10,1:10]
162-
@test co[20:30,20:30] A[1:30,1:30][20:30,20:30]
169+
@test Matrix(co[1:10,1:10]) A10m
170+
@test Matrix(co[20:30,20:30]) A30_2030m
163171

164172
let C=cache(A)
165173
resizedata!(C,5,35)
166174
resizedata!(C,10,35)
167-
@test C.data[1:10,1:C.datasize[2]] A[1:10,1:C.datasize[2]]
175+
@test Matrix(C.data[1:10,1:C.datasize[2]]) Matrix(A[1:10,1:C.datasize[2]])
168176
end
169177
end
170178

171179
# Check that the tests pass after conversion as well
172180
function testinfoperator(A::Operator{T}) where T<:Real
173181
backend_testinfoperator(A)
174-
backend_testinfoperator(strictconvert(Operator{Float64}, A))
175-
backend_testinfoperator(strictconvert(Operator{Float32}, A))
176-
backend_testinfoperator(strictconvert(Operator{ComplexF64}, A))
182+
if T != Float64
183+
B = strictconvert(Operator{Float64}, A)
184+
backend_testinfoperator(B)
185+
end
186+
if T != Float32
187+
B = strictconvert(Operator{Float32}, A)
188+
backend_testinfoperator(B)
189+
end
190+
B = strictconvert(Operator{ComplexF64}, A)
191+
backend_testinfoperator(B)
177192
end
178193

179194
function testinfoperator(A::Operator{T}) where T<:Complex
180195
backend_testinfoperator(A)
181-
backend_testinfoperator(strictconvert(Operator{ComplexF32}, A))
182-
backend_testinfoperator(strictconvert(Operator{ComplexF64}, A))
196+
if T != ComplexF32
197+
backend_testinfoperator(strictconvert(Operator{ComplexF32}, A))
198+
end
199+
if T != ComplexF64
200+
backend_testinfoperator(strictconvert(Operator{ComplexF64}, A))
201+
end
183202
end
184203

185204
function testraggedbelowoperator(A)

0 commit comments

Comments
 (0)