@@ -12,14 +12,16 @@ at input point `z` to confirm that there are correct `frule` and `rrule`s provid
12
12
- `fdm`: the finite differencing method to use.
13
13
- `fkwargs` are passed to `f` as keyword arguments.
14
14
- 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.
15
16
- All remaining keyword arguments are passed to `isapprox`.
16
17
"""
17
- function test_scalar (f, z; rtol= 1e-9 , atol= 1e-9 , fdm= _fdm, fkwargs= NamedTuple (), check_inferred= true , kwargs... )
18
+ function test_scalar (f, z; rtol= 1e-9 , atol= 1e-9 , fdm= _fdm, fkwargs= NamedTuple (), check_inferred= true , testset_name = nothing , kwargs... )
18
19
# To simplify some of the calls we make later lets group the kwargs for reuse
19
20
rule_test_kwargs = (; rtol= rtol, atol= atol, fdm= fdm, fkwargs= fkwargs, check_inferred= check_inferred, kwargs... )
20
21
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
22
+ testset_name = isnothing (testset_name) ? " test_scalar: $f at $z " : testset_name
21
23
22
- @testset " test_scalar: $f at $z " begin
24
+ @testset " $(testset_name) " begin
23
25
# z = x + im * y
24
26
# Ω = u(x, y) + im * v(x, y)
25
27
Ω = f (z; fkwargs... )
89
91
- If `check_inferred=true`, then the inferrability (type-stability) of the `frule` is checked,
90
92
as long as `f` is itself inferrable.
91
93
- `fkwargs` are passed to `f` as keyword arguments.
94
+ - `testset_name`: if provided, the name of the testset used to wrap the tests.
92
95
- All remaining keyword arguments are passed to `isapprox`.
93
96
"""
94
97
function test_frule (args... ; kwargs... )
@@ -106,15 +109,16 @@ function test_frule(
106
109
fkwargs:: NamedTuple = NamedTuple (),
107
110
rtol:: Real = 1e-9 ,
108
111
atol:: Real = 1e-9 ,
112
+ testset_name= nothing ,
109
113
kwargs... ,
110
114
)
111
115
# To simplify some of the calls we make later lets group the kwargs for reuse
112
116
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
113
-
117
+ testset_name = isnothing (testset_name) ? " test_frule: $f on $( _string_typeof (args)) " : testset_name
114
118
# and define a helper closure
115
119
call_on_copy (f, xs... ) = deepcopy (f)(deepcopy (xs)... ; deepcopy (fkwargs)... )
116
120
117
- @testset " test_frule: $f on $( _string_typeof (args) )" begin
121
+ @testset " $(testset_name )" begin
118
122
119
123
primals_and_tangents = auto_primal_and_tangent .((f, args... ))
120
124
primals = primal .(primals_and_tangents)
164
168
- If `check_inferred=true`, then the inferrability (type-stability) of the `rrule` is checked
165
169
— if `f` is itself inferrable — along with the inferrability of the pullback it returns.
166
170
- `fkwargs` are passed to `f` as keyword arguments.
171
+ - `testset_name`: if provided, the name of the testset used to wrap the tests.
167
172
- All remaining keyword arguments are passed to `isapprox`.
168
173
"""
169
174
function test_rrule (args... ; kwargs... )
@@ -182,11 +187,12 @@ function test_rrule(
182
187
fkwargs:: NamedTuple = NamedTuple (),
183
188
rtol:: Real = 1e-9 ,
184
189
atol:: Real = 1e-9 ,
190
+ testset_name= nothing ,
185
191
kwargs... ,
186
192
)
187
193
# To simplify some of the calls we make later lets group the kwargs for reuse
188
194
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
189
-
195
+ testset_name = isnothing (testset_name) ? " test_rrule: $f on $( _string_typeof (args)) " : testset_name
190
196
# and define helper closure over fkwargs
191
197
call (f, xs... ) = f (xs... ; fkwargs... )
192
198
0 commit comments