Skip to content

Commit 9a16131

Browse files
authored
Fix bug in Taylor1 constructor for mixtures and add tests (#343)
* Fix bug in Taylor1 constructor for mixtures and add tests * Remove show in tests
1 parent 5895948 commit 9a16131

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TaylorSeries"
22
uuid = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
33
repo = "https://github.com/JuliaDiff/TaylorSeries.jl.git"
4-
version = "0.15.2"
4+
version = "0.15.3"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/constructors.jl

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

test/mixtures.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,26 @@ using Test
347347
@test_throws ArgumentError Taylor1(2) - TaylorN(1)
348348
@test_throws ArgumentError Taylor1(2) * TaylorN(1)
349349
@test_throws ArgumentError TaylorN(2) / Taylor1(1)
350+
351+
# Issue #342 and PR #343
352+
z0N = -1.333+get_variables()[1]
353+
z = Taylor1(z0N,20)
354+
z[20][1][1] = 5.0
355+
@test z[0][0][1] == -1.333
356+
@test z[20][1][1] == 5.0
357+
for i in 1:19
358+
for j in eachindex(z[i].coeffs)
359+
@test all(z[i].coeffs[j][:] .== 0.0)
360+
end
361+
end
362+
@test all(z[20][1][2:end] .== 0.0)
363+
intz = integrate(z)
364+
intz[20] = z[0]
365+
@test intz[1] == z[0]
366+
@test intz[20] == z[0]
367+
for i in 2:19
368+
@test iszero(intz[i])
369+
end
350370
end
351371

352372
@testset "Tests with nested Taylor1s" begin

0 commit comments

Comments
 (0)