@@ -6,7 +6,7 @@ using Random
66using ForwardDiff
77using ForwardDiff: Partials, Dual, value, partials
88
9- using NaNMath, SpecialFunctions
9+ using NaNMath, SpecialFunctions, LogExpFunctions
1010using DiffRules
1111
1212import Calculus
@@ -420,12 +420,22 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
420420 @test abs (NESTED_FDNUM) === NESTED_FDNUM
421421
422422 if V != Int
423- for (M, f, arity) in DiffRules. diffrules ()
424- in (f, (:hankelh1 , :hankelh1x , :hankelh2 , :hankelh2x , :/ , :rem2pi )) && continue
423+ for (M, f, arity) in DiffRules. diffrules (filter_modules = nothing )
424+ if f in (:hankelh1 , :hankelh1x , :hankelh2 , :hankelh2x , :/ , :rem2pi )
425+ continue # Skip these rules
426+ elseif ! (isdefined (@__MODULE__ , M) && isdefined (getfield (@__MODULE__ , M), f))
427+ continue # Skip rules for methods not defined in the current scope
428+ end
425429 println (" ...auto-testing $(M) .$(f) with $arity arguments" )
426430 if arity == 1
427431 deriv = DiffRules. diffrule (M, f, :x )
428- modifier = in (f, (:asec , :acsc , :asecd , :acscd , :acosh , :acoth )) ? one (V) : zero (V)
432+ modifier = if in (f, (:asec , :acsc , :asecd , :acscd , :acosh , :acoth ))
433+ one (V)
434+ elseif in (f, (:log1mexp , :log2mexp ))
435+ - one (V)
436+ else
437+ zero (V)
438+ end
429439 @eval begin
430440 x = rand () + $ modifier
431441 dx = $ M.$ f (Dual {TestTag()} (x, one (x)))
0 commit comments