Skip to content

Commit

Permalink
Fixed test Radial 1D
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoro committed Jun 8, 2019
1 parent 36f4b20 commit 571f369
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/Radials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ Add new samples x and y and updates the coefficients. Return the new object radi
"""
function add_point!(rad::RadialBasis,new_x,new_y)
if Base.size(rad.x,1) == 1
rad.x = hcat(rad.x, new_x)
rad.y = vcat(vec(rad.y), new_y)
return RadialBasis(rad.x,rad.y,rad.bounds[1],rad.bounds[2],rad.phi,rad.dim_poly)
if length(new_x) > 1
rad.x = hcat(rad.x, new_x)
rad.y = vcat(rad.y, new_y)
return RadialBasis(rad.x,rad.y,rad.bounds[1],rad.bounds[2],rad.phi,rad.dim_poly)
else
rad.x = vcat(vec(rad.x),new_x)
rad.y = vcat(vec(rad.y),new_y)
return RadialBasis(rad.x,rad.y,rad.bounds[1],rad.bounds[2],rad.phi,rad.dim_poly)
end
else
rad.x = vcat(rad.x,new_x)
rad.y = vcat(rad.y,new_y)
Expand Down
7 changes: 5 additions & 2 deletions test/Radials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using Surrogates
est = my_rad(3)
@test est 7.875


#WITH ADD_POINT, adding singleton
x = [1 2 3]
y = [4,5,6]
Expand All @@ -26,15 +27,17 @@ using Surrogates
est = my_rad2(3)
@test est 6.499999999999991


#WITH ADD_POINT, adding more
x = [1 2 3]
y = [4,5,6]
a = 0
b = 4
my_rad = RadialBasis(x,y,a,b,z->norm(z),1)
est_rad = my_rad(3)
my_rad2= add_point!(my_rad,[3.2 3.3 3.4],[8,9,10])
est = my_rad(3)
@test est 6.49416593818781
est_rad2 = my_rad2(3)
@test est_rad2 6.49416593818781

end

Expand Down

0 comments on commit 571f369

Please sign in to comment.