Skip to content

Commit

Permalink
Fix bug in pow! with test (#270)
Browse files Browse the repository at this point in the history
* Fix bug in pow! with test

* Add  another test

* Bump patch version
  • Loading branch information
lbenet authored Apr 8, 2021
1 parent 1a52669 commit 41ad89d
Show file tree
Hide file tree
Showing 3 changed files with 8 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.10.11"
version = "0.10.12"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
2 changes: 1 addition & 1 deletion src/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ exploits `k_0`, the order of the first non-zero coefficient of `a`.
end

# Relevant for positive integer r, to avoid round-off errors
if isinteger(r) && (k > r*findlast(a))
if isinteger(r) && r > 0 && (k > r*findlast(a))
@inbounds c[k] = zero(a[0])
return nothing
end
Expand Down
6 changes: 6 additions & 0 deletions test/onevariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ Base.iszero(::SymbNumber) = false
@test Taylor1(BigFloat,5)/6 == 1im*Taylor1(5)/complex(0,BigInt(6))
@test Taylor1(BigFloat,5)/(6*Taylor1(3)) == 1/BigInt(6)
@test Taylor1(BigFloat,5)/(6im*Taylor1(3)) == -1im/BigInt(6)
@test isapprox((1+(1.5+t)/4)^(-2), inv(1+(1.5+t)/4)^2, rtol=eps(Float64))
@test isapprox((1+(big(1.5)+t)/4)^(-2), inv(1+(big(1.5)+t)/4)^2, rtol=eps(BigFloat))
@test isapprox((1+(1.5+t)/4)^(-2), inv(1+(1.5+t)/4)^2, rtol=eps(Float64))
@test isapprox((1+(big(1.5)+t)/4)^(-2), inv(1+(big(1.5)+t)/4)^2, rtol=eps(BigFloat))
@test isapprox((1+(1.5+t)/5)^(-2.5), inv(1+(1.5+t)/5)^2.5, rtol=eps(Float64))
@test isapprox((1+(big(1.5)+t)/5)^(-2.5), inv(1+(big(1.5)+t)/5)^2.5, rtol=2eps(BigFloat))

# These tests involve some sort of factorization
@test t/(t+t^2) == 1/(1+t)
Expand Down

2 comments on commit 41ad89d

@lbenet
Copy link
Member Author

@lbenet lbenet commented on 41ad89d Apr 8, 2021

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/33863

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.10.12 -m "<description of version>" 41ad89d36d1fb6e6a34c2df4bbb2fb51f6a4386c
git push origin v0.10.12

Please sign in to comment.