#NEWLINE# def get_vtk_array_type( numeric_array_type ) : #NEWLINE# #INDENT# 'Returns a VTK typecode given a numpy array.' #NEWLINE# _arr_vtk = { #NEWLINE# #INDENT# numpy . dtype ( numpy . character ) : vtkConstants . VTK_UNSIGNED_CHAR , #NEWLINE# numpy . dtype ( numpy . uint8 ) : vtkConstants . VTK_UNSIGNED_CHAR , #NEWLINE# numpy . dtype ( numpy . uint16 ) : vtkConstants . VTK_UNSIGNED_SHORT , #NEWLINE# numpy . dtype ( numpy . int8 ) : vtkConstants . VTK_CHAR , #NEWLINE# numpy . dtype ( numpy . int16 ) : vtkConstants . VTK_SHORT , #NEWLINE# numpy . dtype ( numpy . int32 ) : vtkConstants . VTK_INT , #NEWLINE# numpy . dtype ( numpy . uint32 ) : vtkConstants . VTK_UNSIGNED_INT , #NEWLINE# numpy . dtype ( numpy . float32 ) : vtkConstants . VTK_FLOAT , #NEWLINE# numpy . dtype ( numpy . float64 ) : vtkConstants . VTK_DOUBLE , #NEWLINE# numpy . dtype ( numpy . complex64 ) : vtkConstants . VTK_FLOAT , #NEWLINE# numpy . dtype ( numpy . complex128 ) : vtkConstants . VTK_DOUBLE , #NEWLINE# #UNINDENT# } #NEWLINE# _extra = { #NEWLINE# #INDENT# numpy . dtype ( ID_TYPE_CODE ) : vtkConstants . VTK_ID_TYPE , #NEWLINE# numpy . dtype ( ULONG_TYPE_CODE ) : vtkConstants . VTK_UNSIGNED_LONG , #NEWLINE# numpy . dtype ( LONG_TYPE_CODE ) : vtkConstants . VTK_LONG , #NEWLINE# #UNINDENT# } #NEWLINE# for t in _extra : #NEWLINE# #INDENT# if ( t not in _arr_vtk ) : #NEWLINE# #INDENT# _arr_vtk [ t ] = _extra [ t ] #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# return _arr_vtk [ numeric_array_type ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# for key in _arr_vtk : #NEWLINE# #INDENT# if numpy . issubdtype ( key , key ) : #NEWLINE# #INDENT# return _arr_vtk [ key ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise TypeError ( "Couldn't translate array's type to VTK" )