-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
kwargs.sg
32 lines (21 loc) · 1.08 KB
/
kwargs.sg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Keyword arguments are supported when constructing objects
# Either when using factory functions:
#Kernel k1 = kernel_factory(param=2)
#Kernel k2 = kernel_factory("GaussianKernel", c=1.0)
# Or when constructing objects from class constructors
#SomeKernelClass k3(1, a=2, b=3)
# This fails (keyword arguments appear before normal arguments)
#Kernel k4(asd=123, "SomeParam", kw=val)
# This fails (keywords not allowed outside initialisations of variables)
#k4 = kernel_factory("GaussianKernel", b=2)
# This fails (keywords not allowed outside initialisation of variables)
#Kernel k5 = kernel_factory("GaussianKernel", a=glob_fun(kw=123))
# This is fine:
#Kernel k6 = kernel_factory("GaussianKernel", a=glob_fun(ordinary_argument))
# This also fails (keywords not allowed outside initialisation variables)
#kernel_factory("GaussianKernel", a=glob_fun(ordinary_argument))
# Real example
# ------------
Kernel k = kernel("GaussianKernel", log_width=2.0)
KernelMachine svm = kernel_machine("LibSVM", C1=1.1, kernel=k)
KernelMachine svm2 = kernel_machine("LibSVM", kernel=kernel("GaussianKernel"))