MCPcopy Create free account
hub / github.com/Kitware/VTK / testArray

Method testArray

Common/Core/Testing/Python/TestExpects.py:28–73  ·  view source on GitHub ↗

Test values, tuples, components of arrays

(self)

Source from the content-addressed store, hash-verified

26 points.SetPoint(1, p)
27
28 def testArray(self):
29 """Test values, tuples, components of arrays
30 """
31 array = vtkDoubleArray()
32 array.SetNumberOfComponents(2)
33 t = (2.0, 10.0)
34 array.InsertNextTuple(t)
35 array.InsertNextTuple(t)
36 array.InsertNextTuple(t)
37 self.assertEqual(array.GetTuple(0), t)
38 self.assertEqual(array.GetTuple(2), t)
39 with self.assertRaises(ValueError):
40 array.GetTuple(-1)
41 with self.assertRaises(ValueError):
42 array.GetTuple(3)
43 with self.assertRaises(ValueError):
44 array.SetTuple(-1, t)
45 with self.assertRaises(ValueError):
46 array.SetTuple(3, t)
47 self.assertEqual(array.GetValue(0), 2.0)
48 self.assertEqual(array.GetValue(5), 10.0)
49 with self.assertRaises(ValueError):
50 array.GetValue(-1)
51 with self.assertRaises(ValueError):
52 array.GetValue(6)
53 with self.assertRaises(ValueError):
54 array.SetValue(-1, 2.0)
55 with self.assertRaises(ValueError):
56 array.SetValue(6, 10.0)
57 self.assertEqual(array.GetComponent(0, 1), 10.0)
58 with self.assertRaises(ValueError):
59 array.GetComponent(0, -1)
60 with self.assertRaises(ValueError):
61 array.GetComponent(0, 2)
62 with self.assertRaises(ValueError):
63 array.GetComponent(-1, 0)
64 with self.assertRaises(ValueError):
65 array.GetComponent(3, 1)
66 with self.assertRaises(ValueError):
67 array.SetComponent(0, -1, 0.0)
68 with self.assertRaises(ValueError):
69 array.SetComponent(0, 2, 0.0)
70 with self.assertRaises(ValueError):
71 array.SetComponent(-1, 0, 0.0)
72 with self.assertRaises(ValueError):
73 array.SetComponent(3, 1, 0.0)
74
75if __name__ == "__main__":
76 Testing.main([(TestExpects, 'test')])

Callers

nothing calls this directly

Calls 9

vtkDoubleArrayFunction · 0.50
SetNumberOfComponentsMethod · 0.45
InsertNextTupleMethod · 0.45
GetTupleMethod · 0.45
SetTupleMethod · 0.45
GetValueMethod · 0.45
SetValueMethod · 0.45
GetComponentMethod · 0.45
SetComponentMethod · 0.45

Tested by

no test coverage detected