Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Loess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ function loess(
Base.require_one_based_indexing(xs)
Base.require_one_based_indexing(ys)

if size(xs, 1) != size(ys, 1)
if size(xs, 1) != length(ys)
throw(DimensionMismatch("Predictor and response arrays must of the same length"))
end
if isempty(ys)
throw(ArgumentError("input arrays are empty"))
end

n, m = size(xs)
q = floor(Int, span * n)
q = max(1, floor(Int, span * n))

# TODO: We need to keep track of how we are normalizing so we can
# correctly apply predict to unnormalized data. We should have a normalize
Expand Down
8 changes: 4 additions & 4 deletions src/kd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ end


struct KDTree{T <: AbstractFloat}
xs::Matrix{T} # A matrix of n, m-dimensional observations
perm::Vector{Int} # permutation of data to avoid modifying xs
root::KDNode{T} # root node
xs::Matrix{T} # A matrix of n, m-dimensional observations
perm::Vector{Int} # permutation of data to avoid modifying xs
root::Union{Nothing, KDNode{T}} # root node
verts::Set{Vector{T}}
bounds::Matrix{T} # Top-level bounding box
bounds::Matrix{T} # Top-level bounding box
end


Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,9 @@ end
end
end
end

@testset "small datasets. Issue 82" begin
ft = loess([1.0], [1.0])
@test predict(ft, 1.0) == 1.0
@test_throws ArgumentError loess(Float64[], Float64[])
end