@@ -12,14 +12,17 @@ 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.
16
+ Otherwise it is determined from the function and argument types.
15
17
- All remaining keyword arguments are passed to `isapprox`.
16
18
"""
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... )
18
20
# To simplify some of the calls we make later lets group the kwargs for reuse
19
21
rule_test_kwargs = (; rtol= rtol, atol= atol, fdm= fdm, fkwargs= fkwargs, check_inferred= check_inferred, kwargs... )
20
22
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
23
+ testset_name = isnothing (testset_name) ? " test_scalar: $f at $z " : testset_name
21
24
22
- @testset " test_scalar: $f at $z " begin
25
+ @testset " $(testset_name) " begin
23
26
# z = x + im * y
24
27
# Ω = u(x, y) + im * v(x, y)
25
28
Ω = f (z; fkwargs... )
89
92
- If `check_inferred=true`, then the inferrability (type-stability) of the `frule` is checked,
90
93
as long as `f` is itself inferrable.
91
94
- `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.
92
97
- All remaining keyword arguments are passed to `isapprox`.
93
98
"""
94
99
function test_frule (args... ; kwargs... )
@@ -106,15 +111,16 @@ function test_frule(
106
111
fkwargs:: NamedTuple = NamedTuple (),
107
112
rtol:: Real = 1e-9 ,
108
113
atol:: Real = 1e-9 ,
114
+ testset_name= nothing ,
109
115
kwargs... ,
110
116
)
111
117
# To simplify some of the calls we make later lets group the kwargs for reuse
112
118
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
113
-
119
+ testset_name = isnothing (testset_name) ? " test_frule: $f on $( _string_typeof (args)) " : testset_name
114
120
# and define a helper closure
115
121
call_on_copy (f, xs... ) = deepcopy (f)(deepcopy (xs)... ; deepcopy (fkwargs)... )
116
122
117
- @testset " test_frule: $f on $( _string_typeof (args) )" begin
123
+ @testset " $(testset_name )" begin
118
124
119
125
primals_and_tangents = auto_primal_and_tangent .((f, args... ))
120
126
primals = primal .(primals_and_tangents)
164
170
- If `check_inferred=true`, then the inferrability (type-stability) of the `rrule` is checked
165
171
— if `f` is itself inferrable — along with the inferrability of the pullback it returns.
166
172
- `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.
167
175
- All remaining keyword arguments are passed to `isapprox`.
168
176
"""
169
177
function test_rrule (args... ; kwargs... )
@@ -182,15 +190,16 @@ function test_rrule(
182
190
fkwargs:: NamedTuple = NamedTuple (),
183
191
rtol:: Real = 1e-9 ,
184
192
atol:: Real = 1e-9 ,
193
+ testset_name= nothing ,
185
194
kwargs... ,
186
195
)
187
196
# To simplify some of the calls we make later lets group the kwargs for reuse
188
197
isapprox_kwargs = (; rtol= rtol, atol= atol, kwargs... )
189
-
198
+ testset_name = isnothing (testset_name) ? " test_rrule: $f on $( _string_typeof (args)) " : testset_name
190
199
# and define helper closure over fkwargs
191
200
call (f, xs... ) = f (xs... ; fkwargs... )
192
201
193
- @testset " test_rrule: $f on $( _string_typeof (args) )" begin
202
+ @testset " $(testset_name )" begin
194
203
195
204
# Check correctness of evaluation.
196
205
primals_and_tangents = auto_primal_and_tangent .((f, args... ))
0 commit comments