Skip to content

Commit 36586d7

Browse files
authored
Small fix in Taylor1 constructor? (#346)
* Fix Taylor1 constructor * Add tests * Update tests
1 parent 9437c3f commit 36586d7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/constructors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Taylor1(coeffs::Array{T,1}, order::Int) where {T<:Number} = Taylor1{T}(coeffs, o
4949
Taylor1(coeffs::Array{T,1}) where {T<:Number} = Taylor1(coeffs, length(coeffs)-1)
5050
function Taylor1(x::T, order::Int) where {T<:Number}
5151
v = [zero(x) for _ in 1:order+1]
52-
v[1] = x
52+
v[1] = deepcopy(x)
5353
return Taylor1(v, order)
5454
end
5555

test/mixtures.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,13 @@ using Test
367367
for i in 2:19
368368
@test iszero(intz[i])
369369
end
370+
371+
a = sum(exp.(get_variables()).^2)
372+
b = Taylor1([a])
373+
bcopy = deepcopy(b)
374+
c = Taylor1(constant_term(b),0)
375+
c[0][0][1] = 0.0
376+
b == bcopy
370377
end
371378

372379
@testset "Tests with nested Taylor1s" begin

0 commit comments

Comments
 (0)