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

Method testNumpyView

Common/Core/Testing/Python/TestNumpySupport.py:96–105  ·  view source on GitHub ↗

Test if the numpy and VTK array share the same data.

(self)

Source from the content-addressed store, hash-verified

94 self._check_arrays(res, vtk_arr)
95
96 def testNumpyView(self):
97 "Test if the numpy and VTK array share the same data."
98 # ----------------------------------------
99 # Test if the array is copied or not.
100 a = numpy.array([[1, 2, 3],[4, 5, 6]], 'd')
101 vtk_arr = numpy_to_vtk(a)
102 # Change the numpy array and see if the changes are
103 # reflected in the VTK array.
104 a[0] = [10.0, 20.0, 30.0]
105 self.assertEqual(vtk_arr.GetTuple3(0), (10., 20., 30.))
106
107 def testNumpyConversion(self):
108 "Test that converting data copies data properly."

Callers

nothing calls this directly

Calls 3

numpy_to_vtkFunction · 0.90
arrayMethod · 0.80
GetTuple3Method · 0.80

Tested by

no test coverage detected