22
33using Test
44using InverseFunctions
5+ using Dates
56
67
78foo (x) = inv (exp (- x) + 1 )
1819(f:: Bar )(x) = f. A * x
1920InverseFunctions. inverse (f:: Bar ) = Bar (inv (f. A))
2021
22+ @static if VERSION >= v " 1.6"
23+ _bc_func (f) = Base. Broadcast. BroadcastFunction (f)
24+ else
25+ _bc_func (f) = Base. Fix1 (broadcast, f)
26+ end
2127
2228@testset " inverse" begin
23- @static if VERSION >= v " 1.6"
24- _bc_func (f) = Base. Broadcast. BroadcastFunction (f)
25- else
26- _bc_func (f) = Base. Fix1 (broadcast, f)
27- end
28-
2929 f_without_inverse (x) = 1
3030 @test inverse (f_without_inverse) isa NoInverse
3131 @test_throws ErrorException inverse (f_without_inverse)(42 )
@@ -40,7 +40,9 @@ InverseFunctions.inverse(f::Bar) = Bar(inv(f.A))
4040 @test @inferred (NoInverse (Complex)) isa NoInverse{Type{Complex}}
4141
4242 InverseFunctions. test_inverse (inverse, log, compare = === )
43+ end
4344
45+ @testset " maths" begin
4446 InverseFunctions. test_inverse (! , false )
4547
4648 x = rand ()
@@ -122,3 +124,15 @@ InverseFunctions.inverse(f::Bar) = Bar(inv(f.A))
122124 InverseFunctions. test_inverse (log ∘ foo, x)
123125 end
124126end
127+
128+ @testset " dates" begin
129+ InverseFunctions. test_inverse (Dates. date2epochdays, Date (2020 , 1 , 2 ); compare = === )
130+ InverseFunctions. test_inverse (Dates. datetime2epochms, DateTime (2020 , 1 , 2 , 12 , 34 , 56 ); compare = === )
131+ InverseFunctions. test_inverse (Dates. epochdays2date, Int64 (1234 ); compare = === )
132+ InverseFunctions. test_inverse (Dates. epochms2datetime, Int64 (1234567890 ); compare = === )
133+
134+ InverseFunctions. test_inverse (datetime2unix, DateTime (2020 , 1 , 2 , 12 , 34 , 56 ); compare = === )
135+ InverseFunctions. test_inverse (unix2datetime, 1234.56 ; compare = === )
136+ InverseFunctions. test_inverse (datetime2julian, DateTime (2020 , 1 , 2 , 12 , 34 , 56 ); compare = === )
137+ InverseFunctions. test_inverse (julian2datetime, 1234.56 ; compare = === )
138+ end
0 commit comments