From 6da25579aa7008ef7e3c002b556e7a2dbbbe3f8e Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 13 Sep 2023 16:47:59 +0400 Subject: [PATCH] Throw DomainError for out-of-domain evaluation (#538) --- src/polynomials/chebyshev.jl | 3 ++- test/ChebyshevT.jl | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/polynomials/chebyshev.jl b/src/polynomials/chebyshev.jl index 1d43a2f5..2b42e4b7 100644 --- a/src/polynomials/chebyshev.jl +++ b/src/polynomials/chebyshev.jl @@ -135,7 +135,8 @@ julia> c.(-1:0.5:1) ``` """ function evalpoly(x::S, ch::ChebyshevT) where {S} - x ∉ domain(ch) && throw(ArgumentError("$x outside of domain")) + d = domain(ch) + x ∉ d && throw(DomainError(x, "evaluation point must lie in $d")) evalpoly(x, ch, false) end diff --git a/test/ChebyshevT.jl b/test/ChebyshevT.jl index 6f66e174..5b05b59a 100644 --- a/test/ChebyshevT.jl +++ b/test/ChebyshevT.jl @@ -16,6 +16,8 @@ @test size(p, 1) == size(coeff, 1) @test typeof(p).parameters[2] == eltype(coeff) @test eltype(p) == eltype(coeff) + + @test_throws DomainError p(2) end end