|
1 | 1 | @testitem "BaseParams: calc_shunt_conductance unit tests" setup = [defaults] begin |
2 | | - @testset "Basic Functionality" begin |
3 | | - # Example from docstring |
4 | | - radius_in = 0.01 |
5 | | - radius_ext = 0.02 |
6 | | - rho = 1e9 |
7 | | - g = calc_shunt_conductance(radius_in, radius_ext, rho) |
8 | | - @test isapprox(g, 2.7169e-9, atol=TEST_TOL) |
9 | | - # Lower resistivity increases conductance |
10 | | - g2 = calc_shunt_conductance(0.01, 0.02, 1e8) |
11 | | - @test g2 > g |
12 | | - end |
| 2 | + @testset "Basic Functionality" begin |
| 3 | + # Example from docstring |
| 4 | + r_in = 0.01 |
| 5 | + r_ex = 0.02 |
| 6 | + rho = 1e9 |
| 7 | + g = calc_shunt_conductance(r_in, r_ex, rho) |
| 8 | + @test isapprox(g, 2.7169e-9, atol = TEST_TOL) |
| 9 | + # Lower resistivity increases conductance |
| 10 | + g2 = calc_shunt_conductance(0.01, 0.02, 1e8) |
| 11 | + @test g2 > g |
| 12 | + end |
13 | 13 |
|
14 | | - @testset "Edge Cases" begin |
15 | | - # Collapsing geometry: radius_in -> radius_ext |
16 | | - g = calc_shunt_conductance(0.02, 0.02, 1e9) |
17 | | - @test isinf(g) || isnan(g) |
18 | | - # Very large radii |
19 | | - g = calc_shunt_conductance(1e2, 1e3, 1e9) |
20 | | - @test isfinite(g) |
21 | | - # Inf/NaN input |
22 | | - @test isnan(calc_shunt_conductance(NaN, 0.02, 1e9)) |
23 | | - @test isnan(calc_shunt_conductance(0.01, NaN, 1e9)) |
24 | | - @test isnan(calc_shunt_conductance(0.01, 0.02, NaN)) |
25 | | - end |
| 14 | + @testset "Edge Cases" begin |
| 15 | + # Collapsing geometry: r_in -> r_ex |
| 16 | + g = calc_shunt_conductance(0.02, 0.02, 1e9) |
| 17 | + @test isinf(g) || isnan(g) |
| 18 | + # Very large radii |
| 19 | + g = calc_shunt_conductance(1e2, 1e3, 1e9) |
| 20 | + @test isfinite(g) |
| 21 | + # Inf/NaN input |
| 22 | + @test isnan(calc_shunt_conductance(NaN, 0.02, 1e9)) |
| 23 | + @test isnan(calc_shunt_conductance(0.01, NaN, 1e9)) |
| 24 | + @test isnan(calc_shunt_conductance(0.01, 0.02, NaN)) |
| 25 | + end |
26 | 26 |
|
27 | | - @testset "Numerical Consistency" begin |
28 | | - # Float32 vs Float64 |
29 | | - g_f32 = calc_shunt_conductance(Float32(0.01), Float32(0.02), Float32(1e9)) |
30 | | - g_f64 = calc_shunt_conductance(0.01, 0.02, 1e9) |
31 | | - @test isapprox(g_f32, g_f64, atol=TEST_TOL) |
32 | | - end |
| 27 | + @testset "Numerical Consistency" begin |
| 28 | + # Float32 vs Float64 |
| 29 | + g_f32 = calc_shunt_conductance(Float32(0.01), Float32(0.02), Float32(1e9)) |
| 30 | + g_f64 = calc_shunt_conductance(0.01, 0.02, 1e9) |
| 31 | + @test isapprox(g_f32, g_f64, atol = TEST_TOL) |
| 32 | + end |
33 | 33 |
|
34 | | - @testset "Physical Behavior" begin |
35 | | - # Conductance increases as rho decreases |
36 | | - g1 = calc_shunt_conductance(0.01, 0.02, 1e9) |
37 | | - g2 = calc_shunt_conductance(0.01, 0.02, 1e8) |
38 | | - @test g2 > g1 |
39 | | - # Conductance increases as radii get closer |
40 | | - g3 = calc_shunt_conductance(0.01, 0.011, 1e9) |
41 | | - @test g3 > g1 |
42 | | - end |
| 34 | + @testset "Physical Behavior" begin |
| 35 | + # Conductance increases as rho decreases |
| 36 | + g1 = calc_shunt_conductance(0.01, 0.02, 1e9) |
| 37 | + g2 = calc_shunt_conductance(0.01, 0.02, 1e8) |
| 38 | + @test g2 > g1 |
| 39 | + # Conductance increases as radii get closer |
| 40 | + g3 = calc_shunt_conductance(0.01, 0.011, 1e9) |
| 41 | + @test g3 > g1 |
| 42 | + end |
43 | 43 |
|
44 | | - @testset "Type Stability & Promotion" begin |
45 | | - using Measurements |
46 | | - radius_in = 0.01 |
47 | | - radius_ext = 0.02 |
48 | | - rho = 1e9 |
49 | | - min = measurement(radius_in, 1e-4) |
50 | | - mex = measurement(radius_ext, 1e-4) |
51 | | - mrho = measurement(rho, 1e7) |
52 | | - # All Float64 |
53 | | - res1 = calc_shunt_conductance(radius_in, radius_ext, rho) |
54 | | - @test typeof(res1) == Float64 |
55 | | - # All Measurement |
56 | | - res2 = calc_shunt_conductance(min, mex, mrho) |
57 | | - @test res2 isa Measurement{Float64} |
58 | | - # Mixed: first argument Measurement |
59 | | - res3 = calc_shunt_conductance(min, radius_ext, rho) |
60 | | - @test res3 isa Measurement{Float64} |
61 | | - # Mixed: second argument Measurement |
62 | | - res4 = calc_shunt_conductance(radius_in, mex, rho) |
63 | | - @test res4 isa Measurement{Float64} |
64 | | - # Mixed: third argument Measurement |
65 | | - res5 = calc_shunt_conductance(radius_in, radius_ext, mrho) |
66 | | - @test res5 isa Measurement{Float64} |
67 | | - end |
| 44 | + @testset "Type Stability & Promotion" begin |
| 45 | + using Measurements |
| 46 | + r_in = 0.01 |
| 47 | + r_ex = 0.02 |
| 48 | + rho = 1e9 |
| 49 | + min = measurement(r_in, 1e-4) |
| 50 | + mex = measurement(r_ex, 1e-4) |
| 51 | + mrho = measurement(rho, 1e7) |
| 52 | + # All Float64 |
| 53 | + res1 = calc_shunt_conductance(r_in, r_ex, rho) |
| 54 | + @test typeof(res1) == Float64 |
| 55 | + # All Measurement |
| 56 | + res2 = calc_shunt_conductance(min, mex, mrho) |
| 57 | + @test res2 isa Measurement{Float64} |
| 58 | + # Mixed: first argument Measurement |
| 59 | + res3 = calc_shunt_conductance(min, r_ex, rho) |
| 60 | + @test res3 isa Measurement{Float64} |
| 61 | + # Mixed: second argument Measurement |
| 62 | + res4 = calc_shunt_conductance(r_in, mex, rho) |
| 63 | + @test res4 isa Measurement{Float64} |
| 64 | + # Mixed: third argument Measurement |
| 65 | + res5 = calc_shunt_conductance(r_in, r_ex, mrho) |
| 66 | + @test res5 isa Measurement{Float64} |
| 67 | + end |
68 | 68 |
|
69 | | - @testset "Uncertainty Quantification" begin |
70 | | - using Measurements |
71 | | - min = measurement(0.01, 1e-4) |
72 | | - mex = measurement(0.02, 1e-4) |
73 | | - mrho = measurement(1e9, 1e7) |
74 | | - g = calc_shunt_conductance(min, mex, mrho) |
75 | | - @test g isa Measurement{Float64} |
76 | | - @test uncertainty(g) > 0 |
77 | | - end |
| 69 | + @testset "Uncertainty Quantification" begin |
| 70 | + using Measurements |
| 71 | + min = measurement(0.01, 1e-4) |
| 72 | + mex = measurement(0.02, 1e-4) |
| 73 | + mrho = measurement(1e9, 1e7) |
| 74 | + g = calc_shunt_conductance(min, mex, mrho) |
| 75 | + @test g isa Measurement{Float64} |
| 76 | + @test uncertainty(g) > 0 |
| 77 | + end |
78 | 78 | end |
0 commit comments