316
316
@test quantile (all_q, 0.975 ) ≈ uppers[j][i]
317
317
end
318
318
end
319
+
320
+ # Using average leading edge
321
+ _indices = rand (eachindex (sol), 40 )
322
+ q, r, means, lowers, uppers, knots = node_densities (sol; indices= _indices, use_extrema= false )
323
+ @inferred node_densities (sol; indices= _indices, use_extrema= false )
324
+ @test all (≈ (LinRange (0 , 30 , 500 )), knots)
325
+ for (enum_k, k) in enumerate (_indices)
326
+ for j in rand (1 : length (sol[k]), 40 )
327
+ for i in rand (1 : length (sol[k][j]), 60 )
328
+ if i == 1
329
+ @test q[enum_k][j][1 ] ≈ 1 / (r[enum_k][j][2 ] - r[enum_k][j][1 ])
330
+ elseif i == length (sol[k][j])
331
+ n = length (sol[k][j])
332
+ @test q[enum_k][j][n] ≈ 1 / (r[enum_k][j][n] - r[enum_k][j][n- 1 ])
333
+ else
334
+ @test q[enum_k][j][i] ≈ 2 / (r[enum_k][j][i+ 1 ] - r[enum_k][j][i- 1 ])
335
+ end
336
+ @test r[enum_k][j][i] == sol[k][j][i]
337
+ end
338
+ end
339
+ end
340
+ for j in rand (1 : length (fvm_sol), 50 )
341
+ for i in rand (1 : length (knots[j]), 50 )
342
+ all_q = [LinearInterpolation (q[k][j], r[k][j])(knots[j][i]) for k in eachindex (_indices)]
343
+ @test mean (all_q) ≈ means[j][i]
344
+ @test quantile (all_q, 0.025 ) ≈ lowers[j][i]
345
+ @test quantile (all_q, 0.975 ) ≈ uppers[j][i]
346
+ end
347
+ end
319
348
end
320
349
321
350
@testset " Proliferation with a Moving Boundary" begin
519
548
@test quantile (all_q, 0.975 ) ≈ uppers[j][i] rtol = 1e-3
520
549
end
521
550
end
551
+
552
+ # Using the average leading edge
553
+ (; L) = leading_edges (sol)
554
+ _L = stack (L)
555
+ _indices = rand (eachindex (sol), 20 )
556
+ _L = _L[:, _indices]
557
+ _mL = mean .(eachrow (_L))
558
+ q, r, means, lowers, uppers, knots = node_densities (sol; indices= _indices, use_extrema= false )
559
+ @inferred node_densities (sol; indices= _indices, use_extrema= false )
560
+ for j in eachindex (knots)
561
+ a = mean (sol[k][j][begin ] for k in _indices)
562
+ b = mean (sol[k][j][end ] for k in _indices)
563
+ @test knots[j] ≈ LinRange (a, b, 500 )
564
+ @test knots[j][end ] ≈ _mL[j]
565
+ end
566
+ for (enum_k, k) in enumerate (_indices)
567
+ for j in rand (1 : length (sol[k]), 40 )
568
+ for i in 1 : length (sol[k][j])
569
+ if i == 1
570
+ @test q[enum_k][j][1 ] ≈ 1 / (r[enum_k][j][2 ] - r[enum_k][j][1 ])
571
+ elseif i == length (sol[k][j])
572
+ n = length (sol[k][j])
573
+ @test q[enum_k][j][n] ≈ 1 / (r[enum_k][j][n] - r[enum_k][j][n- 1 ])
574
+ else
575
+ @test q[enum_k][j][i] ≈ 2 / (r[enum_k][j][i+ 1 ] - r[enum_k][j][i- 1 ])
576
+ end
577
+ @test r[enum_k][j][i] == sol[k][j][i]
578
+ end
579
+ end
580
+ end
581
+ for j in rand (eachindex (mb_sol), 40 )
582
+ for i in eachindex (knots[j])
583
+ all_q = max .(0.0 , [LinearInterpolation (q[k][j], r[k][j])(knots[j][i]) * (knots[j][i] ≤ r[k][j][end ]) for k in eachindex (_indices)])
584
+ @test mean (all_q) ≈ means[j][i] rtol = 1e-3
585
+ @test quantile (all_q, 0.025 ) ≈ lowers[j][i] rtol = 1e-3
586
+ @test quantile (all_q, 0.975 ) ≈ uppers[j][i] rtol = 1e-3
587
+ end
588
+ end
522
589
end
0 commit comments