def numpy_to_vtkIdTypeArray(num_array, deep=0):
    isize = vtkIdTypeArray().GetDataTypeSize()
    dtype = num_array.dtype
    if isize == 4:
        if dtype != numpy.int32:
            raise ValueError('Expecting a numpy.int32 array, got %s instead.' %
                             (str(dtype)))
    else:
        if dtype != numpy.int64:
            raise ValueError('Expecting a numpy.int64 array, got %s instead.' %
                             (str(dtype)))

    return numpy_to_vtk(num_array, deep, vtkConstants.VTK_ID_TYPE)
 - You need to make sure you hold a reference to a Numpy array you want
   to import into VTK.  If not you'll get a segfault (in the best case).
   The same holds in reverse when you convert a VTK array to a numpy
   array -- don't delete the VTK array.


Created by Prabhu Ramachandran in Feb. 2008.
"""

from . import vtkConstants
from vtkmodules.vtkCommonCore import vtkDataArray, vtkIdTypeArray, vtkLongArray
import numpy

# Useful constants for VTK arrays.
VTK_ID_TYPE_SIZE = vtkIdTypeArray().GetDataTypeSize()
if VTK_ID_TYPE_SIZE == 4:
    ID_TYPE_CODE = numpy.int32
elif VTK_ID_TYPE_SIZE == 8:
    ID_TYPE_CODE = numpy.int64

VTK_LONG_TYPE_SIZE = vtkLongArray().GetDataTypeSize()
if VTK_LONG_TYPE_SIZE == 4:
    LONG_TYPE_CODE = numpy.int32
    ULONG_TYPE_CODE = numpy.uint32
elif VTK_LONG_TYPE_SIZE == 8:
    LONG_TYPE_CODE = numpy.int64
    ULONG_TYPE_CODE = numpy.uint64


def get_vtk_array_type(numpy_array_type):