def pointInGrid(A_point, a_gridSize, *args):
b_wrapGridEdges = False <EOL>if len(args): b_wrapGridEdges = args[<NUM_LIT:0>]<EOL>if b_wrapGridEdges:<EOL><INDENT>W = where(A_point < <NUM_LIT:0>)<EOL>A_point[W] += a_gridSize[W[<NUM_LIT:1>]]<EOL><DEDENT>Wbool = A_point >= <NUM_LIT:0><EOL>W = Wbool.prod(axis=<NUM_LIT:1>)<EOL>A_point = A_point[where(W > <NUM_LIT:0>)]<EOL>A_inGrid = a_gridSize - A_point<EOL>if b_wrapGridEdges:<EOL><INDENT>W = where(A_inGrid <= <NUM_LIT:0>)<EOL>A_point[W] = -A_inGrid[W]<EOL>A_inGrid = a_gridSize - A_point<EOL><DEDENT>Wbool = A_inGrid > <NUM_LIT:0><EOL>W = Wbool.prod(axis=<NUM_LIT:1>)<EOL>A_point = A_point[where(W > <NUM_LIT:0>)]<EOL><INDENT>A_point = abs(A_point)<EOL><DEDENT>return A_point<EOL>
SYNOPSIS

    [A_point] = pointInGrid(A_point, a_gridSize [, ab_wrapGridEdges])

ARGS

    INPUT
    A_point        array of N-D points     points in grid space
    a_gridSize     array                   the size (rows, cols) of
                                           + the grid space

    OPTIONAL
    ab_wrapGridEdges        bool          if True, wrap "external"
                                          points back into grid

    OUTPUT
    A_point        array of N-D points     points that are within the
                                           grid.

DESC
    Determines if set of N-dimensionals <A_point> is within a grid
    <a_gridSize>.

PRECONDITIONS
    o Assumes strictly positive domains, i.e. points with negative
      locations are by definition out-of-range. If negative domains
      are valid in a particular problem space, the caller will need
      to offset <a_point> to be strictly positive first.

POSTCONDITIONS
    o if <ab_wrapGridEdges> is False, returns only the subset of points
      in A_point that are within the <a_gridSize>.
    o if <ab_wrapGridEdges> is True, "wraps" any points in A_point
      back into a_gridSize first, and then checks for those that
      are still within <a_gridSize>.