<commit_before>import numpy as np
from six.moves import range

from ...utils.jaggedarray import JaggedArray
from .status import CORE_NODE, CLOSED_BOUNDARY


def _split_link_ends(link_ends):
    """
    Examples
    --------
    >>> from landlab.grid.unstructured.links import _split_link_ends
    >>> _split_link_ends(((0, 1, 2), (3, 4, 5)))
    (array([0, 1, 2]), array([3, 4, 5]))
    >>> _split_link_ends([(0, 3), (1, 4), (2, 5)])
    (array([0, 1, 2]), array([3, 4, 5]))
    >>> _split_link_ends((0, 3))
    (array([0]), array([3]))
    """
    if len(link_ends) < 2:
        raise ValueError('Link array must be at least of length 2')
    elif len(link_ends) == 2:
        start, end = link_ends
    else:
        start, end = zip(*link_ends)

    try:
        if len(start) == len(end):
            return np.array(start).ravel(), np.array(end).ravel()
        else:
            raise ValueError('Link arrays must be the same length')
    except TypeError:
        return np.array(start).ravel(), np.array(end).ravel()
<commit_msg>Fix _split_link_ends for Python 3.<commit_after>import numpy as np
from six.moves import range

from ...utils.jaggedarray import JaggedArray
from .status import CORE_NODE, CLOSED_BOUNDARY


def _split_link_ends(link_ends):
    """
    Examples
    --------
    >>> from landlab.grid.unstructured.links import _split_link_ends
    >>> _split_link_ends(((0, 1, 2), (3, 4, 5)))
    (array([0, 1, 2]), array([3, 4, 5]))
    >>> _split_link_ends([(0, 3), (1, 4), (2, 5)])
    (array([0, 1, 2]), array([3, 4, 5]))
    >>> _split_link_ends((0, 3))
    (array([0]), array([3]))
    """
    links = np.array(list(link_ends))
    len_of_links = len(links)

    if len_of_links > 2:
        return (links[:, 0], links[:, 1])
    elif len_of_links == 2:
        return (links[0], links[1])
    elif len_of_links == 0:
        return (np.array([], dtype=np.int), np.array([], dtype=np.int))
    else:
        raise ValueError('Link array must be at least of length 2')

{'fraction_non_alphanumeric': 0.17711991971901656, 'fraction_numerical': 0.03411941796287005, 'mean_word_length': 2.940711462450593, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4992042', 'n_tokens_mistral': 751, 'n_tokens_neox': 701, 'n_words': 189}