File: test_libsvm.py

package info (click to toggle)
python-scipy 0.5.2-0.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 33,888 kB
  • ctags: 44,231
  • sloc: ansic: 156,256; cpp: 90,347; python: 89,604; fortran: 73,083; sh: 1,318; objc: 424; makefile: 342
file content (36 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (2)
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
33
34
35
36
from numpy.testing import *
import numpy as N

set_local_path('../..')
import svm.libsvm as libsvm
restore_path()

class test_libsvm(NumpyTestCase):
    def check_svm_node(self):
        node = libsvm.svm_node()
        node = N.empty((), dtype=libsvm.svm_node_dtype)
        node = N.empty((1,), dtype=libsvm.svm_node_dtype)
        node[0]['index'] = 123
        node[0]['value'] = 456.
        assert_equal(node[0][0], 123)
        assert_equal(node[0][1], 456.)

    def check_svm_parameter(self):
        param = libsvm.svm_parameter()
        param.degree = 3
        param.gamma = 1.0

    def check_svm_problem(self):
        problem = libsvm.svm_problem()
        problem.l = 123

    def check_svm_model(self):
        model = libsvm.svm_model()
        model.nr_class = 123
        param = libsvm.svm_parameter()
        param.degree = 3
        model.param = param
        assert_equal(model.param.degree, 3)

if __name__ == '__main__':
    NumpyTest().run()