def valid_box(box, host_extent):
    """Returns True if the entire box is within a grid of size host_extent.

    input arguments (unmodified):
       box: numpy int array of shape (2, 3)
          lower & upper indices in 3 dimensions defining a logical cuboid subset of a 3D cartesian grid
          in python protocol of zero base, kji (normally) or ijk ordering same as for host_extent
       host_extent: triple int
          the extent (shape) of a 3D cartesian grid

    returns: boolean
       True if box is a valid box within a grid of shape host_extent, False otherwise
    """

    if box.ndim != 2 or box.shape != (2, 3) or box.dtype != 'int':
        return False
    if len(host_extent) != 3:
        return False
    for d in range(3):
        if box[0, d] < 0 or box[0, d] > box[1, d] or box[1, d] >= host_extent[d]:
            return False
    return True