MCPcopy Create free account
hub / github.com/davisking/dlib / test_sparse_vector

Function test_sparse_vector

tools/python/test/test_sparse_vector.py:28–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27
28def test_sparse_vector():
29 sv = sparse_vector()
30 sv.append(pair(3, .1))
31 sv.append(pair(3, .2))
32 sv.append(pair(2, .3))
33 sv.append(pair(1, .4))
34
35 assert len(sv) == 4
36 make_sparse_vector(sv)
37
38 assert len(sv) == 3
39 assert sv[0].first == 1
40 assert sv[0].second == .4
41 assert sv[1].first == 2
42 assert sv[1].second == .3
43 assert sv[2].first == 3
44 assert sv[2].second == approx(.3)
45
46 assert str(sv) == "1: 0.4\n2: 0.3\n3: 0.3"
47 assert repr(sv) == "< dlib.sparse_vector containing: \n1: 0.4\n2: 0.3\n3: 0.3 >"
48
49
50def test_sparse_vectors():

Callers

nothing calls this directly

Calls 6

pairClass · 0.90
make_sparse_vectorFunction · 0.90
lenFunction · 0.85
strClass · 0.85
reprFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected