示例#1
0
 def test_map_append(self):
     v = SparseMap()
     s = FloatArray([1, 2, 3])
     v.append(1, s)
     s.free()
     self.assertDictEqual(dict(v.items()), {1: [1, 2, 3]})
     v.free()
示例#2
0
 def test_map_append(self):
     v = SparseMap()
     s = FloatArray([1, 2, 3])
     v.append(1, s)
     s.free()
     self.assertDictEqual(dict(v.items()), {1: [1, 2, 3]})
     v.free()
示例#3
0
 def test_map_map_from_dict(self):
     a = FloatArray([ 1, 2, 3, 4 ])
     b = FloatArray([ 2, 4, 6, 8 ])
     v = SparseMap({ 1: a, 3: b })
     self.assertDictEqual(dict(v.items()), { 1: [1, 2, 3, 4], 3: [2, 4, 6, 8] })
     v.free()
     a.free()
     b.free()
示例#4
0
 def test_map_buffer_offset(self):
     a = FloatArray([1])
     b = FloatArray([1, 2, 3])
     v = SparseMap({1: a, 3: b})
     buf = v.buffer(byte_offset=8)
     a.free()
     b.free()
     v.free()
     copy = SparseMap(buf, len(buf))
     self.assertDictEqual(dict(copy.items()), {3: [1, 2, 3]})
     copy.free()
示例#5
0
 def test_map_map_from_dict(self):
     a = FloatArray([1, 2, 3, 4])
     b = FloatArray([2, 4, 6, 8])
     v = SparseMap({1: a, 3: b})
     self.assertDictEqual(dict(v.items()), {
         1: [1, 2, 3, 4],
         3: [2, 4, 6, 8]
     })
     v.free()
     a.free()
     b.free()
示例#6
0
 def test_map_buffer_offset(self):
     a = FloatArray([1])
     b = FloatArray([1, 2, 3])
     v = SparseMap({1: a, 3: b})
     buf = v.buffer(byte_offset=8)
     a.free()
     b.free()
     v.free()
     copy = SparseMap(buf, len(buf))
     self.assertDictEqual(dict(copy.items()), {3: [1, 2, 3]})
     copy.free()
示例#7
0
 def test_map_import_export(self):
     a = FloatArray([ 1, 2, 3, 4 ])
     b = FloatArray([ 2, 4, 6, 8 ])
     v = SparseMap({ 1: a, 3: b })
     buf = v.buffer()
     a.free()
     b.free()
     v.free()
     self.assertEqual(len(buf), 40)
     copy = SparseMap(buf, len(buf))
     self.assertDictEqual(dict(copy.items()), { 1: [1, 2, 3, 4], 3: [2, 4, 6, 8] })
     copy.free()
     v = SparseMap()
     self.assertEqual(v.buffer(), None)
     v.free()
示例#8
0
 def test_map_import_export(self):
     a = FloatArray([1, 2, 3, 4])
     b = FloatArray([2, 4, 6, 8])
     v = SparseMap({1: a, 3: b})
     buf = v.buffer()
     a.free()
     b.free()
     v.free()
     self.assertEqual(len(buf), 40)
     copy = SparseMap(buf, len(buf))
     self.assertDictEqual(dict(copy.items()), {
         1: [1, 2, 3, 4],
         3: [2, 4, 6, 8]
     })
     copy.free()
     v = SparseMap()
     self.assertEqual(v.buffer(), None)
     v.free()
示例#9
0
 def test_map_empty_map(self):
     v = SparseMap()
     self.assertDictEqual(dict(v.items()), {})
     self.assertEqual(v.byte_length(), 0)
     v.free()
示例#10
0
 def test_map_empty_map(self):
     v = SparseMap()
     self.assertDictEqual(dict(v.items()), {})
     self.assertEqual(v.byte_length(), 0)
     v.free()