diff --git a/Project.toml b/Project.toml index 591a5759..2075eeed 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TaylorSeries" uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea" repo = "https://github.com/JuliaDiff/TaylorSeries.jl.git" -version = "0.15.2" +version = "0.15.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/constructors.jl b/src/constructors.jl index a4953aaf..2c40aa71 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -48,7 +48,7 @@ Taylor1(x::Taylor1{T}) where {T<:Number} = x Taylor1(coeffs::Array{T,1}, order::Int) where {T<:Number} = Taylor1{T}(coeffs, order) Taylor1(coeffs::Array{T,1}) where {T<:Number} = Taylor1(coeffs, length(coeffs)-1) function Taylor1(x::T, order::Int) where {T<:Number} - v = fill(zero(x), order+1) + v = [zero(x) for _ in 1:order+1] v[1] = x return Taylor1(v, order) end diff --git a/test/mixtures.jl b/test/mixtures.jl index dfb26ac6..374de8dd 100644 --- a/test/mixtures.jl +++ b/test/mixtures.jl @@ -347,6 +347,26 @@ using Test @test_throws ArgumentError Taylor1(2) - TaylorN(1) @test_throws ArgumentError Taylor1(2) * TaylorN(1) @test_throws ArgumentError TaylorN(2) / Taylor1(1) + + # Issue #342 and PR #343 + z0N = -1.333+get_variables()[1] + z = Taylor1(z0N,20) + z[20][1][1] = 5.0 + @test z[0][0][1] == -1.333 + @test z[20][1][1] == 5.0 + for i in 1:19 + for j in eachindex(z[i].coeffs) + @test all(z[i].coeffs[j][:] .== 0.0) + end + end + @test all(z[20][1][2:end] .== 0.0) + intz = integrate(z) + intz[20] = z[0] + @test intz[1] == z[0] + @test intz[20] == z[0] + for i in 2:19 + @test iszero(intz[i]) + end end @testset "Tests with nested Taylor1s" begin