Skip to content

Commit

Permalink
fix issue with integer-valued find_zeros (#260)
Browse files Browse the repository at this point in the history
* fix issue with integer-valued find_zeros

* version bump
  • Loading branch information
jverzani committed Nov 17, 2021
1 parent 1889dd0 commit f013dad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Roots"
uuid = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
version = "1.3.8"
version = "1.3.9"

[deps]
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
Expand Down
4 changes: 2 additions & 2 deletions src/find_zeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ The algorithm is derived from one in a
!!! note
The `IntervalRootFinding` package provides a rigorous alternative to this heuristic one.
That package use interval arithmetic, so can compute bounds on the size of the image of
That package uses interval arithmetic, so can compute bounds on the size of the image of
an interval under `f`. If this image includes `0`, then it can look for the zero.
Bisection, on the other hand, only will look for a zero if the two endpoints have different signs,
a much more rigid condition for a potential zero.
Expand Down Expand Up @@ -304,7 +304,7 @@ function find_zeros(f, a, b=nothing; no_pts=12, k=8, naive=false, kwargs...)
b0 = isinf(b0) ? prevfloat(b0) : b0

# set tolerances if not specified
fa0, fb0 = f(a0), f(b0)
fa0, fb0 = promote(float(f(a0)), float(f(b0)))
d = Dict(kwargs)
T, S = eltype(a0), eltype(fa0)
xatol::T = get(d, :xatol, eps(one(T))^(4 / 5) * oneunit(T))
Expand Down
3 changes: 3 additions & 0 deletions test/test_find_zeros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ end
@test find_zeros(sin, 3:4) [float(pi)]
@test find_zeros(sin, SomeInterval(3, 4)) [float(pi)]
@test find_zeros(sin, range(3, stop=4, length=20)) [float(pi)]

# test with constant function
@test isempty(find_zeros(x -> 4, -10, 10))
end

@testset "find_zeros: not Float64 types" begin
Expand Down

2 comments on commit f013dad

@jverzani
Copy link
Member Author

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

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 v1.3.9 -m "<description of version>" f013dad2ee22b6a2e91609135e41bae59a3ec1f7
git push origin v1.3.9

Please sign in to comment.