Skip to content

Commit c342866

Browse files
committed
Address review comments
1 parent 543d0c8 commit c342866

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Loess.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ function loess(
4444
degree::Integer = 2,
4545
cell::AbstractFloat = 0.2
4646
) where T<:AbstractFloat
47+
48+
Base.require_one_based_indexing(xs)
49+
Base.require_one_based_indexing(ys)
50+
4751
if size(xs, 1) != size(ys, 1)
4852
throw(DimensionMismatch("Predictor and response arrays must of the same length"))
4953
end
@@ -177,18 +181,22 @@ end
177181

178182
function predict(model::LoessModel, zs::AbstractVector)
179183
if size(model.xs, 2) > 1
180-
throw(ArgumentError("Multivariate blending not yet implemented"))
184+
throw(ArgumentError("multivariate blending not yet implemented"))
181185
end
182186

183-
predict.(Ref(model), zs)
187+
return [predict(model, z) for z in zs]
184188
end
185189

186190
function predict(model::LoessModel, zs::AbstractMatrix)
187-
if size(model.xs, 2) > 1
188-
throw(ArgumentError("Multivariate blending not yet implemented"))
191+
if size(model.xs, 2) != size(zs, 2)
192+
throw(DimensionMismatch("number of columns in input matrix must match the number of columns in the model matrix"))
189193
end
190194

191-
return [predict(model, z) for z in vec(zs)]
195+
if size(zs, 2) == 1
196+
return predict(model, vec(zs))
197+
else
198+
return [predict(model, row) for row in eachrow(zs)]
199+
end
192200
end
193201

194202
"""

src/kd.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ function traverse(kdtree::KDTree{T}, x::NTuple{N,T}) where {N,T}
256256

257257
for j in 1:N
258258
if x[j] < kdtree.bounds[1, j] || x[j] > kdtree.bounds[2, j]
259-
@show x, kdtree.bounds
260259
error(
261260
"""
262261
Loess cannot perform extrapolation. Predict can only be applied

0 commit comments

Comments
 (0)