(dom_i, dom_j, cod_j, grid)
return (free_up, free_down, backwards)
For a horizontal morphism, checks whether there is free space
        (i.e., space not occupied by any objects) above the morphism
        or below it.
For a horizontal morphism, checks whether there is free space
        (i.e., space not occupied by any objects) above the morphism
        or below it.
For a horizontal morphism checks whether there is free space ( i . e . space not occupied by any objects ) above the morphism or below it .
def _check_free_space_horizontal(dom_i, dom_j, cod_j, grid):
        """
        For a horizontal morphism, checks whether there is free space
        (i.e., space not occupied by any objects) above the morphism
        or below it.
        """
        if dom_j < cod_j:
            (start, end) = (dom_j, cod_j)
            backwards = False
        else:
            (start, end) = (cod_j, dom_j)
            backwards = True

        # Check for free space above.
        if dom_i == 0:
            free_up = True
        else:
            free_up = all([grid[dom_i - 1, j] for j in
                           xrange(start, end + 1)])

        # Check for free space below.
        if dom_i == grid.height - 1:
            free_down = True
        else:
            free_down = all([not grid[dom_i + 1, j] for j in
                             xrange(start, end + 1)])

        return (free_up, free_down, backwards)
def _check_free_space_horizontal ( dom_i , dom_j , cod_j , grid ) : if dom_j < cod_j : ( start , end ) = ( dom_j , cod_j ) backwards = False else : ( start , end ) = ( cod_j , dom_j ) backwards = True # Check for free space above. if dom_i == 0 : free_up = True else : free_up = all ( [ grid [ dom_i - 1 , j ] for j in xrange ( start , end + 1 ) ] ) # Check for free space below. if dom_i == grid . height - 1 : free_down = True else : free_down = all ( [ not grid [ dom_i + 1 , j ] for j in xrange ( start , end + 1 ) ] ) return ( free_up , free_down , backwards )