Skip to content

Commit

Permalink
throw ArgumentError instead of assertion for wrong derivative_order
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Jun 14, 2024
1 parent 7f54a30 commit b62f40b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/SummationByPartsOperatorsOptimForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function SummationByPartsOperators.function_space_operator(basis_functions, node
derivative_order = 1, accuracy_order = 0,
options = Options(g_tol = 1e-14, iterations = 10000)) where {T, SourceOfCoefficients}

@assert derivative_order == 1 "Only first derivative operators are supported"
if derivative_order != 1
throw(ArgumentError("Derivative order $derivative_order not implemented."))
end
sort!(nodes)
weights, D = construct_function_space_operator(basis_functions, nodes, source; options = options)
return MatrixDerivativeOperator(first(nodes), last(nodes), nodes, weights, D, accuracy_order, source)
Expand Down
2 changes: 2 additions & 0 deletions test/matrix_operators_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ if VERSION >= v"1.9"
B[N, N] = 1.0
let basis_functions = [x -> x^i for i in 0:3]
D = function_space_operator(basis_functions, nodes, source)
# Only first-derivative operators are implemented yet
@test_throws ArgumentError function_space_operator(basis_functions, nodes, source; derivative_order = 2)

@test grid(D) nodes
@test all(isapprox.(D * ones(N), zeros(N); atol = 1e-13))
Expand Down

0 comments on commit b62f40b

Please sign in to comment.