def get_index_dtype(arrays=(), maxval=None, check_contents=False):
 int32max = np.iinfo(np.int32).max
 dtype = np.intc
 if (maxval is not None):
  if (maxval > int32max):
   dtype = np.int64
 if isinstance(arrays, np.ndarray):
  arrays = (arrays,)
 for arr in arrays:
  arr = np.asarray(arr)
  if (arr.dtype > np.int32):
   if check_contents:
    if (arr.size == 0):
     continue
    elif np.issubdtype(arr.dtype, np.integer):
     maxval = arr.max()
     minval = arr.min()
     if ((minval >= np.iinfo(np.int32).min) and (maxval <= np.iinfo(np.int32).max)):
      continue
   dtype = np.int64
   break
 return dtype

def get_index_dtype ( arrays = ( ) , maxval = None , check_contents = False ) : int32max = np . iinfo ( np . int32 ) . max dtype = np . intc if ( maxval is not None ) : if ( maxval > int32max ) : dtype = np . int64 if isinstance ( arrays , np . ndarray ) : arrays = ( arrays , ) for arr in arrays : arr = np . asarray ( arr ) if ( arr . dtype > np . int32 ) : if check_contents : if ( arr . size == 0 ) : continue elif np . issubdtype ( arr . dtype , np . integer ) : maxval = arr . max ( ) minval = arr . min ( ) if ( ( minval >= np . iinfo ( np . int32 ) . min ) and ( maxval <= np . iinfo ( np . int32 ) . max ) ) : continue dtype = np . int64 break return dtype
based on input arrays a .