Skip to content

Commit f02f722

Browse files
committed
Separate convenience funcs from GPR.jl
1 parent 6e63890 commit f02f722

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/ConvenienceFunctions.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
const RPAD = 25
3+
4+
function name(name::AbstractString)
5+
return rpad(name * ":", RPAD)
6+
end
7+
8+
function warn(name::AbstractString)
9+
return rpad("WARNING (" * name * "):", RPAD)
10+
end
11+
12+

src/GPR.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ using Parameters # lets you have defaults for fields
99
using EllipsisNotation # adds '..' to refer to the rest of array
1010
import ScikitLearn
1111
import StatsBase
12+
include("ConvenienceFunctions.jl")
13+
1214
const sklearn = ScikitLearn
1315

1416
sklearn.@sk_import gaussian_process : GaussianProcessRegressor
@@ -324,19 +326,6 @@ function plot_fit(gprw::Wrap, plt; plot_95 = false, label = nothing)
324326
end
325327
end
326328

327-
################################################################################
328-
# convenience functions ########################################################
329-
################################################################################
330-
const RPAD = 25
331-
332-
function name(name::AbstractString)
333-
return rpad(name * ":", RPAD)
334-
end
335-
336-
function warn(name::AbstractString)
337-
return rpad("WARNING (" * name * "):", RPAD)
338-
end
339-
340329
end # module
341330

342331

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Test
2+
3+
include("../../src/ConvenienceFunctions.jl")
4+
5+
################################################################################
6+
# unit testing #################################################################
7+
################################################################################
8+
@testset "unit testing" begin
9+
@test isdefined(Main, :RPAD)
10+
@test length(name("a")) == RPAD
11+
@test length(name("a" ^ RPAD)) == (RPAD + 1)
12+
@test length(warn("a")) == RPAD
13+
@test length(warn("a" ^ RPAD)) == (RPAD + 11)
14+
@test isa(name("a"), String)
15+
@test isa(warn("a"), String)
16+
end
17+
println("")
18+
19+

0 commit comments

Comments
 (0)