From 5d9eedb734ea6ce6c934cc895229a35ffeebba00 Mon Sep 17 00:00:00 2001 From: "Bowen S. Zhu" Date: Sat, 12 Nov 2022 20:51:11 -0500 Subject: [PATCH] Avoid construction of `EmptyQuad` in type checking --- src/auxfuns.jl | 4 ++-- src/tensor.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auxfuns.jl b/src/auxfuns.jl index 76b2036..ce6b8b2 100644 --- a/src/auxfuns.jl +++ b/src/auxfuns.jl @@ -23,7 +23,7 @@ nw(mop::MultiOrthoPoly) ``` returns nodes and weights in matrix form """ -nw(quad::typeof(EmptyQuad())) = Array{Float64}(undef, 0, 2) +nw(::EmptyQuad) = Array{Float64}(undef, 0, 2) function nw(quad::AbstractQuad) [quad.nodes quad.weights] @@ -89,7 +89,7 @@ function integrate(f::Function, nodes::AbstractVector{<:Real}, end function integrate(f::Function, quad::AbstractQuad) - typeof(quad) == typeof(EmptyQuad()) && + quad isa EmptyQuad && throw(DomainError(quad, "supplied an empty quadrature")) integrate(f, quad.nodes, quad.weights) end diff --git a/src/tensor.jl b/src/tensor.jl index 6c9ec48..5fb1ee1 100644 --- a/src/tensor.jl +++ b/src/tensor.jl @@ -25,13 +25,13 @@ function computeTensorizedSP(m::Integer, op::AbstractVector, ind::AbstractMatrix end function computeTensorizedSP(m::Integer, mop::MultiOrthoPoly) - any([typeof(op.quad) == typeof(EmptyQuad()) for op in mop.uni]) && + any(op.quad isa EmptyQuad for op in mop.uni) && throw(InconsistencyError("at least one quadrature rule missing")) computeTensorizedSP(m, mop.uni, mop.ind) end function computeTensorizedSP(m::Integer, op::AbstractOrthoPoly) - typeof(op.quad) == typeof(EmptyQuad()) && + op.quad isa EmptyQuad && throw(InconsistencyError("no quadrature rule provided")) computeTensorizedSP(m, [op], calculateMultiIndices(1, deg(op))) end