We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf9bb03 commit 7776b6bCopy full SHA for 7776b6b
test/Nonlinear/Nonlinear.jl
@@ -1408,6 +1408,18 @@ function test_create_binary_switch()
1408
return
1409
end
1410
1411
+function test_intercept_ForwardDiff_MethodError()
1412
+ r = Nonlinear.OperatorRegistry()
1413
+ f(x::Float64) = sin(x)^2
1414
+ g(x) = x > 1 ? f(x) : zero(x)
1415
+ Nonlinear.register_operator(r, :g, 1, g)
1416
+ @test Nonlinear.eval_univariate_function(r, :g, 0.0) == 0.0
1417
+ @test Nonlinear.eval_univariate_function(r, :g, 2.0) ≈ sin(2.0)^2
1418
+ @test Nonlinear.eval_univariate_gradient(r, :g, 0.0) == 0.0
1419
+ @test_throws ErrorException Nonlinear.eval_univariate_function(r, :g, 2.0)
1420
+ return
1421
+end
1422
+
1423
end # TestNonlinear
1424
1425
TestNonlinear.runtests()
0 commit comments