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

Method __new__

Wrapping/Python/vtkmodules/numpy_interface/dataset_adapter.py:263–279  ·  view source on GitHub ↗
(cls, input_array, array=None, dataset=None)

Source from the content-addressed store, hash-verified

261 return getattr(numpy.ndarray, attr_name)(l[0], l[1])
262
263 def __new__(cls, input_array, array=None, dataset=None):
264 # Input array is an already formed ndarray instance
265 # We first cast to be our class type
266 obj = numpy.asarray(input_array).view(cls)
267 obj.Association = ArrayAssociation.FIELD
268 # add the new attributes to the created instance
269 obj.VTKObject = array
270 if dataset:
271 obj._dataset = vtkWeakReference()
272 if issubclass(type(dataset), vtkObject):
273 # New dataset API.
274 obj._dataset.Set(dataset)
275 else:
276 # Old dataset type object with WrapDataObject
277 obj._dataset.Set(dataset.VTKObject)
278 # Finally, we must return the newly created object:
279 return obj
280
281 def __array_finalize__(self,obj):
282 # Copy the VTK array only if the two share data

Callers 4

__new__Method · 0.45
__new__Method · 0.45
__new__Method · 0.45

Calls 3

typeEnum · 0.50
viewMethod · 0.45
SetMethod · 0.45

Tested by 1