Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
mikeingold and github-actions[bot] authored Dec 5, 2024
1 parent d8d6a87 commit ebed239
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions test/combinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
end
end

function runtests(testable::TestableGeometry, supports::SupportStatus; rtol=sqrt(eps()))
function runtests(
testable::TestableGeometry, supports::SupportStatus; rtol = sqrt(eps()))
# Test alias functions
for alias in (lineintegral, surfaceintegral, volumeintegral)
alias_symbol = first(methods(alias)).name
if getfield(supports, alias_symbol)
@test alias(testable.integrand, testable.geometry) testable.solution rtol=rtol
@test alias(testable.integrand, testable.geometry)testable.solution rtol=rtol
else
@test_throws "not supported" alias(testable.integrand, testable.geometry)
end
Expand All @@ -75,18 +76,19 @@
if supported
# Scalar integrand
sol = testable.solution
@test integral(testable.integrand, testable.geometry, rule) sol rtol=rtol
@test integral(testable.integrand, testable.geometry, rule)sol rtol=rtol

# Callable integrand
f = Callable(testable.integrand)
@test integral(f, testable.geometry, rule) sol rtol=rtol
@test integral(f, testable.geometry, rule)sol rtol=rtol

# Vector integrand
fv(p) = fill(testable.integrand(p), 3)
sol_v = fill(testable.solution, 3)
@test integral(fv, testable.geometry, rule) sol_v rtol=rtol
@test integral(fv, testable.geometry, rule)sol_v rtol=rtol
else
@test_throws "not supported" integral(testable.integrand, testable.geometry, rule)
@test_throws "not supported" integral(
testable.integrand, testable.geometry, rule)
end # if
end # for
end # function
Expand Down Expand Up @@ -150,7 +152,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, curve, solution)
runtests(testable, SupportStatus(:line); rtol=0.5e-2)
runtests(testable, SupportStatus(:line); rtol = 0.5e-2)
end

@testitem "Meshes.Box 1D" setup=[Combinations] begin
Expand All @@ -167,7 +169,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:line); rtol=1e-6)
runtests(testable, SupportStatus(:line); rtol = 1e-6)
end

@testitem "Meshes.Box 2D" setup=[Combinations] begin
Expand All @@ -183,7 +185,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Box 3D" setup=[Combinations] begin
Expand All @@ -200,7 +202,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, box, solution)
runtests(testable, SupportStatus(:volume); rtol=1e-6)
runtests(testable, SupportStatus(:volume); rtol = 1e-6)
end

@testitem "Meshes.Circle" setup=[Combinations] begin
Expand Down Expand Up @@ -259,7 +261,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, cone, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Cylinder" setup=[Combinations] begin
Expand Down Expand Up @@ -326,7 +328,7 @@ end
# Package and run tests
# Tolerances are higher due to `measure` being only an approximation
testable = TestableGeometry(integrand, ellipsoid, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-2)
runtests(testable, SupportStatus(:surface); rtol = 1e-2)
end

@testitem "Meshes.FrustumSurface" setup=[Combinations] begin
Expand Down Expand Up @@ -358,7 +360,7 @@ end

# Package and run tests
testable = TestableGeometry(integrand, frustum, solution)
runtests(testable, SupportStatus(:surface); rtol=1e-6)
runtests(testable, SupportStatus(:surface); rtol = 1e-6)
end

@testitem "Meshes.Hexahedron" setup=[Combinations] begin
Expand Down
2 changes: 1 addition & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
@test FiniteDifference().ε 1e-6

# Test jacobian with wrong number of parametric coordinates
box = Box(Point(0, 0), Point(1, 1))
box = Box(Point(0, 0), Point(1, 1))
@test_throws ArgumentError jacobian(box, zeros(3))
end

Expand Down

0 comments on commit ebed239

Please sign in to comment.