Skip to content

Commit

Permalink
Fixed warn deprecation + tests raising warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Guevara Vasquez committed Sep 15, 2020
1 parent e961ed9 commit 1bfd9b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Dierckx.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function roots(spline::Spline1D; maxn::Integer=8)
if ier[1] == 0
return zeros[1:m[1]]
elseif ier[1] == 1
warn("number of zeros exceeded maxn; only first maxn zeros returned")
@warn("number of zeros exceeded maxn; only first maxn zeros returned")
return zeros
elseif ier[1] == 10
error("Invalid input data.")
Expand Down Expand Up @@ -825,7 +825,7 @@ function Spline2D(x::AbstractVector, y::AbstractVector, z::AbstractVector;
if (ier[] == 0 || ier[] == -1 || ier[] == -2)
# good values, pass.
elseif ier[] < -2
warn("""
@warn("""
The coefficients of the spline returned have been
computed as the minimal norm least-squares solution of a
(numerically) rank deficient system. The rank is $(-ier[]).
Expand Down
10 changes: 10 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ sp4 = ParametricSpline(x, y.+1)
@test sp1 == sp2
@test allunique([sp1,sp3,sp4])

# test too many roots warning
x = (0:100)
y = (-1).^(0:100)
sp = Spline1D(x,y)
@test_logs (:warn,Regex("number of zeros exceeded")) roots(sp)


# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -321,5 +326,10 @@ sp5 = Spline2D(x, y, z.+1)
@test sp1 == sp2
@test allunique([sp1, sp3, sp4, sp5])

# test bad least squares / rank deficient warning
x = 1.0 .+ (0:100)*2e-16
y = 1.0 .+ (100:-1:0)*2e-16;
z = (-1).^(0:100)
@test_logs (:warn,Regex("rank deficient")) Spline2D(x,y,z,s=85)

println("All tests passed.")

0 comments on commit 1bfd9b0

Please sign in to comment.