Skip to content

Commit

Permalink
Small fix in Taylor1 constructor? (#346)
Browse files Browse the repository at this point in the history
* Fix Taylor1 constructor

* Add tests

* Update tests
  • Loading branch information
PerezHz authored Jan 31, 2024
1 parent 9437c3f commit 36586d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Taylor1(coeffs::Array{T,1}, order::Int) where {T<:Number} = Taylor1{T}(coeffs, o
Taylor1(coeffs::Array{T,1}) where {T<:Number} = Taylor1(coeffs, length(coeffs)-1)
function Taylor1(x::T, order::Int) where {T<:Number}
v = [zero(x) for _ in 1:order+1]
v[1] = x
v[1] = deepcopy(x)
return Taylor1(v, order)
end

Expand Down
7 changes: 7 additions & 0 deletions test/mixtures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ using Test
for i in 2:19
@test iszero(intz[i])
end

a = sum(exp.(get_variables()).^2)
b = Taylor1([a])
bcopy = deepcopy(b)
c = Taylor1(constant_term(b),0)
c[0][0][1] = 0.0
b == bcopy
end

@testset "Tests with nested Taylor1s" begin
Expand Down

0 comments on commit 36586d7

Please sign in to comment.