@@ -12,14 +12,17 @@ at input point `z` to confirm that there are correct `frule` and `rrule`s provid
1212- `fdm`: the finite differencing method to use.
1313- `fkwargs` are passed to `f` as keyword arguments.
1414- If `check_inferred=true`, then the inferrability (type-stability) of the `frule` and `rrule` are checked.
15+ - `testset_name`: if provided, the name of the testset used to wrap the tests.
16+ Otherwise it is determined from the function and argument types.
1517- All remaining keyword arguments are passed to `isapprox`.
1618"""
17- function test_scalar (f, z; rtol= 1e-9 , atol= 1e-9 , fdm= _fdm, fkwargs= NamedTuple (), check_inferred= true , kwargs... )
19+ function test_scalar (f, z; rtol= 1e-9 , atol= 1e-9 , fdm= _fdm, fkwargs= NamedTuple (), check_inferred= true , testset_name = nothing , kwargs... )
1820 # To simplify some of the calls we make later lets group the kwargs for reuse
1921 rule_test_kwargs = (; rtol= rtol, atol= atol, fdm= fdm, fkwargs= fkwargs, check_inferred= check_inferred, kwargs... )
2022 isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
23+ testset_name = isnothing (testset_name) ? " test_scalar: $f at $z " : testset_name
2124
22- @testset " test_scalar: $f at $z " begin
25+ @testset " $(testset_name) " begin
2326 # z = x + im * y
2427 # Ω = u(x, y) + im * v(x, y)
2528 Ω = f (z; fkwargs... )
8992 - If `check_inferred=true`, then the inferrability (type-stability) of the `frule` is checked,
9093 as long as `f` is itself inferrable.
9194 - `fkwargs` are passed to `f` as keyword arguments.
95+ - `testset_name`: if provided, the name of the testset used to wrap the tests.
96+ Otherwise it is determined from the function and argument types.
9297 - All remaining keyword arguments are passed to `isapprox`.
9398"""
9499function test_frule (args... ; kwargs... )
@@ -106,15 +111,16 @@ function test_frule(
106111 fkwargs:: NamedTuple = NamedTuple (),
107112 rtol:: Real = 1e-9 ,
108113 atol:: Real = 1e-9 ,
114+ testset_name= nothing ,
109115 kwargs... ,
110116)
111117 # To simplify some of the calls we make later lets group the kwargs for reuse
112118 isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
113-
119+ testset_name = isnothing (testset_name) ? " test_frule: $f on $( _string_typeof (args)) " : testset_name
114120 # and define a helper closure
115121 call_on_copy (f, xs... ) = deepcopy (f)(deepcopy (xs)... ; deepcopy (fkwargs)... )
116122
117- @testset " test_frule: $f on $( _string_typeof (args) )" begin
123+ @testset " $(testset_name )" begin
118124
119125 primals_and_tangents = auto_primal_and_tangent .((f, args... ))
120126 primals = primal .(primals_and_tangents)
164170 - If `check_inferred=true`, then the inferrability (type-stability) of the `rrule` is checked
165171 — if `f` is itself inferrable — along with the inferrability of the pullback it returns.
166172 - `fkwargs` are passed to `f` as keyword arguments.
173+ - `testset_name`: if provided, the name of the testset used to wrap the tests.
174+ Otherwise it is determined from the function and argument types.
167175 - All remaining keyword arguments are passed to `isapprox`.
168176"""
169177function test_rrule (args... ; kwargs... )
@@ -182,15 +190,16 @@ function test_rrule(
182190 fkwargs:: NamedTuple = NamedTuple (),
183191 rtol:: Real = 1e-9 ,
184192 atol:: Real = 1e-9 ,
193+ testset_name= nothing ,
185194 kwargs... ,
186195)
187196 # To simplify some of the calls we make later lets group the kwargs for reuse
188197 isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
189-
198+ testset_name = isnothing (testset_name) ? " test_rrule: $f on $( _string_typeof (args)) " : testset_name
190199 # and define helper closure over fkwargs
191200 call (f, xs... ) = f (xs... ; fkwargs... )
192201
193- @testset " test_rrule: $f on $( _string_typeof (args) )" begin
202+ @testset " $(testset_name )" begin
194203
195204 # Check correctness of evaluation.
196205 primals_and_tangents = auto_primal_and_tangent .((f, args... ))
0 commit comments