File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -52,12 +52,15 @@ function loess(
52
52
Base. require_one_based_indexing (xs)
53
53
Base. require_one_based_indexing (ys)
54
54
55
- if size (xs, 1 ) != size (ys, 1 )
55
+ if size (xs, 1 ) != length (ys)
56
56
throw (DimensionMismatch (" Predictor and response arrays must of the same length" ))
57
57
end
58
+ if isempty (ys)
59
+ throw (ArgumentError (" input arrays are empty" ))
60
+ end
58
61
59
62
n, m = size (xs)
60
- q = floor (Int, span * n)
63
+ q = max ( 1 , floor (Int, span * n) )
61
64
62
65
# TODO : We need to keep track of how we are normalizing so we can
63
66
# correctly apply predict to unnormalized data. We should have a normalize
Original file line number Diff line number Diff line change 9
9
10
10
11
11
struct KDTree{T <: AbstractFloat }
12
- xs:: Matrix{T} # A matrix of n, m-dimensional observations
13
- perm:: Vector{Int} # permutation of data to avoid modifying xs
14
- root:: KDNode{T} # root node
12
+ xs:: Matrix{T} # A matrix of n, m-dimensional observations
13
+ perm:: Vector{Int} # permutation of data to avoid modifying xs
14
+ root:: Union{Nothing, KDNode{T}} # root node
15
15
verts:: Set{Vector{T}}
16
- bounds:: Matrix{T} # Top-level bounding box
16
+ bounds:: Matrix{T} # Top-level bounding box
17
17
end
18
18
19
19
Original file line number Diff line number Diff line change 107
107
end
108
108
end
109
109
end
110
+
111
+ @testset " small datasets. Issue 82" begin
112
+ ft = loess ([1.0 ], [1.0 ])
113
+ @test predict (ft, 1.0 ) == 1.0
114
+ @test_throws ArgumentError loess (Float64[], Float64[])
115
+ end
You can’t perform that action at this time.
0 commit comments