| 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 |