(i, j, target_i, grid, morphisms_str_info,
                                   object_coords)
return (curving, label_pos)
Produces the information required for constructing the string
        representation of a vertical morphism.  This function is
        invoked from ``_process_morphism``.

        See Also
        ========

        _process_morphism
Produces the information required for constructing the string
        representation of a vertical morphism.  This function is
        invoked from ``_process_morphism``.
Produces the information required for constructing the string representation of a vertical morphism . This function is invoked from _process_morphism .
def _process_vertical_morphism(i, j, target_i, grid, morphisms_str_info,
                                   object_coords):
        """
        Produces the information required for constructing the string
        representation of a vertical morphism.  This function is
        invoked from ``_process_morphism``.

        See Also
        ========

        _process_morphism
        """
        # This arrow is vertical.  Check if it goes from top to
        # bottom (``backwards == False``) or from bottom to top
        # (``backwards == True``).
        backwards = False
        start = i
        end = target_i
        if end < start:
            (start, end) = (end, start)
            backwards = True

        # Let's see which objects are there between ``start`` and
        # ``end``, and then count how many morphisms stick out to
        # the left, and how many stick out to the right.
        #
        # See the corresponding comment in the previous branch of
        # this if-statement for more details.
        left = []
        right = []
        straight_vertical = []
        for k in xrange(start + 1, end):
            obj = grid[k, j]
            if not obj:
                continue

            for m in morphisms_str_info:
                if m.domain == obj:
                    (end_i, end_j) = object_coords[m.codomain]
                elif m.codomain == obj:
                    (end_i, end_j) = object_coords[m.domain]
                else:
                    continue

                if end_j > j:
                    right.append(m)
                elif end_j < j:
                    left.append(m)
                elif not morphisms_str_info[m].curving:
                    # This is a straight vertical morphism,
                    # because it has no curving.
                    straight_vertical.append(m)

        if len(left) < len(right):
            # More morphisms stick out to the left than to the
            # right, let's curve the morphism to the right.
            if backwards:
                curving = "^"
                label_pos = "^"
            else:
                curving = "_"
                label_pos = "_"

            # Assure that the straight vertical morphisms have
            # their labels on the left side of the arrow.
            for m in straight_vertical:
                (i1, j1) = object_coords[m.domain]
                (i2, j2) = object_coords[m.codomain]

                m_str_info = morphisms_str_info[m]
                if i1 < i2:
                    m_str_info.label_position = "^"
                else:
                    m_str_info.label_position = "_"

                # Don't allow any further modifications of the
                # position of this label.
                m_str_info.forced_label_position = True
        else:
            # More morphisms stick out to the right than to the
            # left, let's curve the morphism to the left.
            if backwards:
                curving = "_"
                label_pos = "_"
            else:
                curving = "^"
                label_pos = "^"

            # Assure that the straight vertical morphisms have
            # their labels on the right side of the arrow.
            for m in straight_vertical:
                (i1, j1) = object_coords[m.domain]
                (i2, j2) = object_coords[m.codomain]

                m_str_info = morphisms_str_info[m]
                if i1 < i2:
                    m_str_info.label_position = "_"
                else:
                    m_str_info.label_position = "^"

                # Don't allow any further modifications of the
                # position of this label.
                m_str_info.forced_label_position = True

        return (curving, label_pos)
def _process_vertical_morphism ( i , j , target_i , grid , morphisms_str_info , object_coords ) : # This arrow is vertical.  Check if it goes from top to # bottom (``backwards == False``) or from bottom to top # (``backwards == True``). backwards = False start = i end = target_i if end < start : ( start , end ) = ( end , start ) backwards = True # Let's see which objects are there between ``start`` and # ``end``, and then count how many morphisms stick out to # the left, and how many stick out to the right. # # See the corresponding comment in the previous branch of # this if-statement for more details. left = [ ] right = [ ] straight_vertical = [ ] for k in xrange ( start + 1 , end ) : obj = grid [ k , j ] if not obj : continue for m in morphisms_str_info : if m . domain == obj : ( end_i , end_j ) = object_coords [ m . codomain ] elif m . codomain == obj : ( end_i , end_j ) = object_coords [ m . domain ] else : continue if end_j > j : right . append ( m ) elif end_j < j : left . append ( m ) elif not morphisms_str_info [ m ] . curving : # This is a straight vertical morphism, # because it has no curving. straight_vertical . append ( m ) if len ( left ) < len ( right ) : # More morphisms stick out to the left than to the # right, let's curve the morphism to the right. if backwards : curving = "^" label_pos = "^" else : curving = "_" label_pos = "_" # Assure that the straight vertical morphisms have # their labels on the left side of the arrow. for m in straight_vertical : ( i1 , j1 ) = object_coords [ m . domain ] ( i2 , j2 ) = object_coords [ m . codomain ] m_str_info = morphisms_str_info [ m ] if i1 < i2 : m_str_info . label_position = "^" else : m_str_info . label_position = "_" # Don't allow any further modifications of the # position of this label. m_str_info . forced_label_position = True else : # More morphisms stick out to the right than to the # left, let's curve the morphism to the left. if backwards : curving = "_" label_pos = "_" else : curving = "^" label_pos = "^" # Assure that the straight vertical morphisms have # their labels on the right side of the arrow. for m in straight_vertical : ( i1 , j1 ) = object_coords [ m . domain ] ( i2 , j2 ) = object_coords [ m . codomain ] m_str_info = morphisms_str_info [ m ] if i1 < i2 : m_str_info . label_position = "_" else : m_str_info . label_position = "^" # Don't allow any further modifications of the # position of this label. m_str_info . forced_label_position = True return ( curving , label_pos )