Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 0d45208

Browse files
committed
fix test_broken to correct, dimensions of 4th order corrected
1 parent c202130 commit 0d45208

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

test/derivative_operators_interface.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,55 +146,56 @@ end
146146

147147
@testset "Correctness of Non-Uniform Stencils" begin
148148
x = [0., 0.08, 0.1, 0.15, 0.19, 0.26, 0.29]
149+
nx = length(x)
149150
dx = diff(x)
150151

151152
# Second-Order First Derivative
152-
L = CenteredDifference(1, 2, dx, 5)
153+
L = CenteredDifference(1, 2, dx, nx-2)
153154
correct = analyticCtrOneTwoIrr()
154155

155156
# Check that stencils agree with correct
156157
for (i,coefs) in enumerate(L.stencil_coefs)
157158
@test Array(coefs) correct[i,correct[i,:] .!= 0.]
158159
end
159-
@test_broken Array(L) correct # All of these concretizations
160-
@test_broken sparse(L) correct # only give the first three
161-
@test_broken BandedMatrix(L) correct # rows of the computed stencil coefficients
160+
@test Array(L) correct
161+
@test sparse(L) correct
162+
@test BandedMatrix(L) correct
162163

163164
# Second-Order Second Derivative
164-
L = CenteredDifference(2, 2, dx, 5)
165+
L = CenteredDifference(2, 2, dx, nx-2)
165166
correct = analyticCtrTwoTwoIrr()
166167

167168
# Check that stencils agree with correct
168169
for (i,coefs) in enumerate(L.stencil_coefs)
169170
@test Array(coefs) correct[i,correct[i,:] .!= 0.]
170171
end
171-
@test_broken Array(L) correct # same issue as previous derivative
172-
@test_broken sparse(L) correct
173-
@test_broken BandedMatrix(L) correct
172+
@test Array(L) correct
173+
@test sparse(L) correct
174+
@test BandedMatrix(L) correct
174175

175176
# Fourth-Order Second Derivative
176-
L = CenteredDifference(2, 4, dx, 5)
177+
L = CenteredDifference(2, 4, dx, nx-2)
177178
correct = analyticCtrTwoFourIrr()
178179

179180
# Check that stencils agree with correct
180181
for (i,coefs) in enumerate(L.stencil_coefs)
181182
@test Array(coefs) correct[i,correct[i,:] .!= 0.]
182183
end
183-
@test_broken Array(L) correct # L.stencil_coefs is populated, but the concretization doesn't work. It appears to be an issue of improper calculation of indexing from the various lengths computed during construction (e.g. boundary_stencil_length, len) and potentially the fact that "len" doesn't seem to specify the number of grid points at which we compute finite differences but appears to specify the location of the last grid point at which we compute finite differences (so if X is a 5-length vector, entering len = 2 means computing FDs for X[2] and X[3])
184-
@test_broken sparse(L) correct
185-
@test_broken BandedMatrix(L) correct
184+
@test Array(L)[2:end-1,:] correct
185+
@test sparse(L)[2:end-1,:] correct
186+
@test BandedMatrix(L)[2:end-1,:] correct
186187

187188
# Second-Order Fourth Derivative
188-
L = CenteredDifference(4, 2, dx, 5)
189+
L = CenteredDifference(4, 2, dx, nx-2)
189190
correct = analyticCtrFourTwoIrr()
190191

191192
# Check that stencils agree with correct
192193
for (i,coefs) in enumerate(L.stencil_coefs)
193194
@test Array(coefs) correct[i,correct[i,:] .!= 0.]
194195
end
195-
@test_broken Array(L) correct
196-
@test_broken sparse(L) correct
197-
@test_broken BandedMatrix(L) correct
196+
@test Array(L)[2:end-1,:] correct
197+
@test sparse(L)[2:end-1,:] correct
198+
@test BandedMatrix(L)[2:end-1,:] correct
198199
end
199200

200201
# tests for full and sparse function

0 commit comments

Comments
 (0)