def normalize_kernel_dimensions(griddim, blockdim):
 def check_dim(dim, name):
  if (not isinstance(dim, (tuple, list))):
   dim = [dim]
  else:
   dim = list(dim)
  if (len(dim) > 3):
   raise ValueError(('%s must be a sequence of 1, 2 or 3 integers, got %r' % (name, dim)))
  for v in dim:
   if (not isinstance(v, numbers.Integral)):
    raise TypeError(('%s must be a sequence of integers, got %r' % (name, dim)))
  while (len(dim) < 3):
   dim.append(1)
  return dim
 griddim = check_dim(griddim, 'griddim')
 blockdim = check_dim(blockdim, 'blockdim')
 return (griddim, blockdim)

def normalize_kernel_dimensions ( griddim , blockdim ) : def check_dim ( dim , name ) : if ( not isinstance ( dim , ( tuple , list ) ) ) : dim = [ dim ] else : dim = list ( dim ) if ( len ( dim ) > 3 ) : raise ValueError ( ( '%s must be a sequence of 1, 2 or 3 integers, got %r' % ( name , dim ) ) ) for v in dim : if ( not isinstance ( v , numbers . Integral ) ) : raise TypeError ( ( '%s must be a sequence of integers, got %r' % ( name , dim ) ) ) while ( len ( dim ) < 3 ) : dim . append ( 1 ) return dim griddim = check_dim ( griddim , 'griddim' ) blockdim = check_dim ( blockdim , 'blockdim' ) return ( griddim , blockdim )
normalize and validate the user-supplied kernel dimensions .