Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check that q is not zero #77

Open
bjarthur opened this issue Aug 16, 2023 · 0 comments
Open

check that q is not zero #77

bjarthur opened this issue Aug 16, 2023 · 0 comments

Comments

@bjarthur
Copy link
Contributor

if q turns out to be zero here, then there is an uncaught exception here. a simple MWE is when length(xs) * span < 1. is it worth throwing an informative error?

julia> using Loess

julia> loess([1,2,3], [4,5,6], span=0.1)
ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type)
    @ Base ./reduce.jl:367
  [2] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, #unused#::Type{Float64})
    @ Base ./reduce.jl:356
  [3] reduce_empty_iter
    @ ./reduce.jl:379 [inlined]
  [4] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Float64}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:375
  [5] _mapreduce(f::typeof(identity), op::typeof(max), #unused#::IndexLinear, A::Vector{Float64})
    @ Base ./reduce.jl:427
  [6] _mapreduce_dim
    @ ./reducedim.jl:365 [inlined]
  [7] #mapreduce#800
    @ ./reducedim.jl:357 [inlined]
  [8] mapreduce
    @ ./reducedim.jl:357 [inlined]
  [9] #_maximum#818
    @ ./reducedim.jl:999 [inlined]
 [10] _maximum
    @ ./reducedim.jl:999 [inlined]
 [11] #_maximum#817
    @ ./reducedim.jl:998 [inlined]
 [12] _maximum
    @ ./reducedim.jl:998 [inlined]
 [13] #maximum#815
    @ ./reducedim.jl:994 [inlined]
 [14] maximum
    @ ./reducedim.jl:994 [inlined]
 [15] loess(xs::Matrix{Float64}, ys::Vector{Float64}; normalize::Bool, span::Float64, degree::Int64, cell::Float64)
    @ Loess ~/.julia/packages/Loess/p2rXa/src/Loess.jl:97
 [16] loess
    @ ~/.julia/packages/Loess/p2rXa/src/Loess.jl:39 [inlined]
 [17] #loess#12
    @ ~/.julia/packages/Loess/p2rXa/src/Loess.jl:142 [inlined]
 [18] loess
    @ ~/.julia/packages/Loess/p2rXa/src/Loess.jl:142 [inlined]
 [19] #loess#13
    @ ~/.julia/packages/Loess/p2rXa/src/Loess.jl:147 [inlined]
 [20] top-level scope
    @ REPL[5]:1

julia> VERSION
v"1.9.2"

(jl_Wt4s1c) pkg> st
Status `/private/var/folders/s5/8d629n5d7nsf37f60_91wzr40000gq/T/jl_Wt4s1c/Project.toml`
  [4345ca2d] Loess v0.6.1

julia> Sys.MACHINE
"arm64-apple-darwin22.4.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant