(dom_i, cod_i, dom_j, grid)
return (free_left, free_right, backwards)
For a vertical morphism, checks whether there is free space
        (i.e., space not occupied by any objects) to the left of the
        morphism or to the right of it.
For a vertical morphism, checks whether there is free space
        (i.e., space not occupied by any objects) to the left of the
        morphism or to the right of it.
For a vertical morphism checks whether there is free space ( i . e . space not occupied by any objects ) to the left of the morphism or to the right of it .
def _check_free_space_vertical(dom_i, cod_i, dom_j, grid):
        """
        For a vertical morphism, checks whether there is free space
        (i.e., space not occupied by any objects) to the left of the
        morphism or to the right of it.
        """
        if dom_i < cod_i:
            (start, end) = (dom_i, cod_i)
            backwards = False
        else:
            (start, end) = (cod_i, dom_i)
            backwards = True

        # Check if there's space to the left.
        if dom_j == 0:
            free_left = True
        else:
            free_left = all([not grid[i, dom_j - 1] for i in
                             xrange(start, end + 1)])

        if dom_j == grid.width - 1:
            free_right = True
        else:
            free_right = all([not grid[i, dom_j + 1] for i in
                              xrange(start, end + 1)])

        return (free_left, free_right, backwards)
def _check_free_space_vertical ( dom_i , cod_i , dom_j , grid ) : if dom_i < cod_i : ( start , end ) = ( dom_i , cod_i ) backwards = False else : ( start , end ) = ( cod_i , dom_i ) backwards = True # Check if there's space to the left. if dom_j == 0 : free_left = True else : free_left = all ( [ not grid [ i , dom_j - 1 ] for i in xrange ( start , end + 1 ) ] ) if dom_j == grid . width - 1 : free_right = True else : free_right = all ( [ not grid [ i , dom_j + 1 ] for i in xrange ( start , end + 1 ) ] ) return ( free_left , free_right , backwards )