Skip to content

Commit

Permalink
Fix bug in Taylor1 constructor for mixtures and add tests (#343)
Browse files Browse the repository at this point in the history
* Fix bug in Taylor1 constructor for mixtures and add tests

* Remove show in tests
  • Loading branch information
PerezHz authored Dec 1, 2023
1 parent 5895948 commit 9a16131
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/mixtures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 9a16131

@lbenet
Copy link
Member

@lbenet lbenet commented on 9a16131 Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/96275

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.15.3 -m "<description of version>" 9a16131fd1ba6a7616c99be084b5142b90b2ed77
git push origin v0.15.3

Please sign in to comment.