Skip to content

Commit 1f4f976

Browse files
committed
Improve coverage
1 parent 37c8657 commit 1f4f976

4 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/chainrules.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ChainRulesCore: rrule, RuleConfig
2-
ChainRulesCore.debug_mode() = true
32

43
@opt_out rrule(::Any, ::TaylorScalar)
54
@opt_out rrule(::Any, ::TaylorScalar, ::TaylorScalar)

src/primitive.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ for func in (:sin, :cos)
5050
c1 = cos(v[1])
5151
end
5252
for i in 2:N
53-
ex = quote
54-
$ex
55-
$(Symbol('s', i)) = +($([:($(binomial(i - 2, j - 1)) * $(Symbol('c', j)) *
56-
v[$i + 1 - $j])
57-
for j in 1:(i - 1)]...))
58-
$(Symbol('c', i)) = +($([:($(-binomial(i - 2, j - 1)) * $(Symbol('s', j)) *
59-
v[$i + 1 - $j])
60-
for j in 1:(i - 1)]...))
61-
end
53+
ex = :($ex;
54+
$(Symbol('s', i)) = +($([:($(binomial(i - 2, j - 1)) *
55+
$(Symbol('c', j)) *
56+
v[$i + 1 - $j]) for j in 1:(i - 1)]...)))
57+
ex = :($ex;
58+
$(Symbol('c', i)) = +($([:($(-binomial(i - 2, j - 1)) *
59+
$(Symbol('s', j)) *
60+
v[$i + 1 - $j]) for j in 1:(i - 1)]...)))
6261
end
6362
if $(QuoteNode(func)) == :sin
6463
ex = :($ex; TaylorScalar($([Symbol('s', i) for i in 1:N]...)))

src/scalar.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,3 @@ function promote_rule(::Type{TaylorScalar{T, N}},
6868
::Type{S}) where {T <: Number, S <: Number, N}
6969
TaylorScalar{promote_type(T, S), N}
7070
end
71-
function promote_rule(::Type{TaylorScalar{T, N}},
72-
::Type{TaylorScalar{S, N}}) where {T <: Number, S <: Number, N}
73-
TaylorScalar{promote_type(T, S), N}
74-
end

test/primitive.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ using FiniteDifferences
77
end
88
for f in (+, -, <, <=, >, >=, ==), order in (2,)
99
@test derivative(x -> f(x, another_number), some_number, order) 0.0
10+
@test derivative(x -> f(another_number, x), some_number, order) 0.0
11+
@test derivative(x -> f(x, x), some_number, order) 0.0
1012
end
1113
end
1214

1315
@testset "Unary functions" begin
1416
some_number = 3.7
15-
for f in (exp, expm1, exp2, exp10, sin, cos, sqrt, cbrt, inv), order in (1, 4)
17+
for f in (x -> exp(x^2), expm1, exp2, exp10, x -> sin(x^2), x -> cos(x^2), sqrt, cbrt,
18+
inv), order in (1, 4)
1619
fdm = central_fdm(12, order)
1720
@test derivative(f, some_number, order)fdm(f, some_number) rtol=1e-6
1821
end

0 commit comments

Comments
 (0)