File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ uuid = "3587e190-3f89-42d0-90ee-14403ec27112"
3
3
version = " 0.1.0"
4
4
5
5
[deps ]
6
+ Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
6
7
7
8
[compat ]
8
9
julia = " 1"
9
10
10
11
[extras ]
11
12
Documenter = " e30172f5-a6a5-5a46-863b-614d45cd2de4"
12
- Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
13
13
14
14
[targets ]
15
- test = [" Documenter" , " Test " ]
15
+ test = [" Documenter" ]
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ Lightweight package that defines an interface to invert functions.
6
6
"""
7
7
module InverseFunctions
8
8
9
+ using Test
10
+
9
11
include (" inverse.jl" )
12
+ include (" test.jl" )
10
13
11
14
end # module
Original file line number Diff line number Diff line change 45
45
Implementations of `inverse(::typeof(f))` have to satisfy
46
46
* `inverse(f)(f(x)) ≈ x` for all `x` in the domain of `f`, and
47
47
* `inverse(inverse(f)) === f`.
48
+
49
+ You can check your implementation with [`InverseFunctions.test_inverse`](@ref).
48
50
"""
49
51
inverse (f)
50
52
export inverse
Original file line number Diff line number Diff line change
1
+ """
2
+ InverseFunctions.test_inverse(f, x; kwargs...)
3
+
4
+ Check if [`inverse(f)`](@ref) is implemented correctly.
5
+
6
+ The function checks if
7
+ - `inverse(f)(f(x)) ≈ x` and
8
+ - `inverse(inverse(f)) === f`.
9
+
10
+ All keyword arguments are passed to `isapprox`.
11
+ """
12
+ function test_inverse (f, x; kwargs... )
13
+ @testset " test_inverse: $f with input $x " begin
14
+ inverse_f = inverse (f)
15
+ @test isapprox (inverse_f (f (x)), x; kwargs... )
16
+ @test inverse (inverse_f) === f
17
+ end
18
+ return nothing
19
+ end
You can’t perform that action at this time.
0 commit comments