<commit_before>from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from compas.utilities import pairwise
from compas.utilities import geometric_key

__all__ = [
    'network_join_edges',
    'network_polylines'
]


# def join_edges_network(network, ab, cd):
#     """Join two edges of a network.
#     """
#     intersection = set(ab) & set(cd)
#     if not intersection:
#         raise Exception('The edges are not connected.')
#     a, b = ab
#     c, d = cd
#     raise NotImplementedError


def network_join_edges(network, key):
    nbrs = network.vertex_neighbors(key)
    if len(nbrs) != 2:
        return
    a, b = nbrs
    if a in network.edge[key]:
        del network.edge[key][a]
    else:
        del network.edge[a][key]
    del network.halfedge[key][a]
    del network.halfedge[a][key]
    if b in network.edge[key]:
        del network.edge[key][b]
    else:
        del network.edge[b][key]
    del network.halfedge[key][b]
    del network.halfedge[b][key]
    del network.vertex[key]
    del network.halfedge[key]
    del network.edge[key]
    # set attributes based on average of two joining edges?
    network.add_edge(a, b)

def network_polylines(network, splits=None):
    """Join network edges into polylines.
    The polylines stop at points with a valency different from 2 in the network of line.
    Optional splits can be included.

    Parameters
    ----------
    network : Network
        A network.
    splits : list, None
        List of point coordinates for optional splits. Default is None.

    Returns
    -------
    polylines: list<commit_msg>correct documentation<commit_after>from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

from compas.utilities import pairwise
from compas.utilities import geometric_key

__all__ = [
    'network_join_edges',
    'network_polylines'
]


# def join_edges_network(network, ab, cd):
#     """Join two edges of a network.
#     """
#     intersection = set(ab) & set(cd)
#     if not intersection:
#         raise Exception('The edges are not connected.')
#     a, b = ab
#     c, d = cd
#     raise NotImplementedError


def network_join_edges(network, key):
    nbrs = network.vertex_neighbors(key)
    if len(nbrs) != 2:
        return
    a, b = nbrs
    if a in network.edge[key]:
        del network.edge[key][a]
    else:
        del network.edge[a][key]
    del network.halfedge[key][a]
    del network.halfedge[a][key]
    if b in network.edge[key]:
        del network.edge[key][b]
    else:
        del network.edge[b][key]
    del network.halfedge[key][b]
    del network.halfedge[b][key]
    del network.vertex[key]
    del network.halfedge[key]
    del network.edge[key]
    # set attributes based on average of two joining edges?
    network.add_edge(a, b)

def network_polylines(network, splits=None):
    """Join network edges into polylines.
    The polylines stop at points with a valency different from 2 in the network of line.
    Optional splits can be included.

    Parameters
    ----------
    network : Network
        A network.
    splits : list, optional
        List of point coordinates for optional splits.
        Default is ''None''.

    Returns
    -------
    polylines: list
{'fraction_non_alphanumeric': 0.10096735187424426, 'fraction_numerical': 0.0012091898428053204, 'mean_word_length': 2.743212669683258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1081546', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1015, 'n_words': 316}