def expand_key(k, dims):
 def inds(i, ind):
  rv = []
  if ((ind - 0.9) > 0):
   rv.append((ind - 0.9))
  rv.append(ind)
  if ((ind + 0.9) < (dims[i] - 1)):
   rv.append((ind + 0.9))
  return rv
 shape = []
 for (i, ind) in enumerate(k[1:]):
  num = 1
  if (ind > 0):
   num += 1
  if (ind < (dims[i] - 1)):
   num += 1
  shape.append(num)
 seq = list(product([k[0]], *[inds(i, ind) for (i, ind) in enumerate(k[1:])]))
 return reshapelist(shape, seq)

def expand_key ( k , dims ) : def inds ( i , ind ) : rv = [ ] if ( ( ind - 0.9 ) > 0 ) : rv . append ( ( ind - 0.9 ) ) rv . append ( ind ) if ( ( ind + 0.9 ) < ( dims [ i ] - 1 ) ) : rv . append ( ( ind + 0.9 ) ) return rv shape = [ ] for ( i , ind ) in enumerate ( k [ 1 : ] ) : num = 1 if ( ind > 0 ) : num += 1 if ( ind < ( dims [ i ] - 1 ) ) : num += 1 shape . append ( num ) seq = list ( product ( [ k [ 0 ] ] , * [ inds ( i , ind ) for ( i , ind ) in enumerate ( k [ 1 : ] ) ] ) ) return reshapelist ( shape , seq )
get all neighboring keys around center .