# Buggy code
def split(
    self,
    ratios: Union[float, Sequence[float]] = 0.8,
    *,
    random_state: Union[None, int, np.random.RandomState] = None,
    randomize_cleanup: bool = False,
) -> List["TriplesFactory"]:
    """Split a triples factory into a train/test.

    :param ratios: There are three options for this argument. First, a float can be given between 0 and 1.0,
     non-inclusive. The first triples factory will get this ratio and the second will get the rest. Second,
     a list of ratios can be given for which factory in which order should get what ratios as in ``[0.8, 0.1]``.
     The final ratio can be omitted because that can be calculated. Third, all ratios can be explicitly set in
     order such as in ``[0.8, 0.1, 0.1]`` where the sum of all ratios is 1.0.
    :param random_state: The random state used to shuffle and split the triples in this factory.
    :param randomize_cleanup: If true, uses the non-deterministic method for moving triples to the training set.
     This has the advantage that it doesn't necessarily have to move all of them, but it might be slower.

    .. code-block:: python

        ratio = 0.8  # makes a [0.8, 0.2] split
        training_factory, testing_factory = factory.split(ratio)

        ratios = [0.8, 0.1]  # makes a [0.8, 0.1, 0.1] split
        training_factory, testing_factory, validation_factory = factory.split(ratios)

        ratios = [0.8, 0.1, 0.1]  # also makes a [0.8, 0.1, 0.1] split
        training_factory, testing_factory, validation_factory = factory.split(ratios)
    """
    n_triples = self.triples.shape[0]

    # Prepare shuffle index
    idx = np.arange(n_triples)
    if random_state is None:
        random_state = np.random.randint(0, 2**32 - 1)
        logger.warning(f"Using random_state={random_state} to split {self}")
    if isinstance(random_state, int):
        random_state = np.random.RandomState(random_state)
    random_state.shuffle(idx)

    # Prepare split index
    if isinstance(ratios, float):
        ratios = [ratios]

    ratio_sum = sum(ratios)
    if ratio_sum == 1.0:
        ratios = ratios[:-1]  # vsplit doesn't take the final number into account.
    elif ratio_sum > 1.0:
        raise ValueError(f"ratios sum to more than 1.0: {ratios} (sum={ratio_sum})")

    sizes = [int(split_ratio * n_triples) for split_ratio in ratios]
    # Take cumulative sum so the get separated properly
    split_idxs = np.cumsum(sizes)

    # Split triples
    triples_groups = np.vsplit(self.triples[idx], split_idxs)
    logger.info(
        f"split triples to groups of sizes {[triples.shape[0] for triples in triples_groups]}"
    )

    # Make sure that the first element has all the right stuff in it
    triples_groups = _tf_cleanup_all(
        triples_groups, random_state=random_state if randomize_cleanup else None
    )

    for i, (triples, exp_size, exp_ratio) in enumerate(
        zip(triples_groups, sizes, ratios)
    ):
        actual_size = triples.shape[0]
        actual_ratio = actual_size / exp_size * exp_ratio
        if actual_size != exp_size:
            logger.warning(
                f"Requested ratio[{i}]={exp_ratio:.3f} (equal to size {exp_size}), but got {actual_ratio:.3f} "
                f"(equal to size {actual_size}) to ensure that all entities/relations occur in train.",
            )

    # Make new triples factories for each group
    return [
        TriplesFactory(
            triples=triples,
            entity_to_id=self.entity_to_id,
            relation_to_id=self.relation_to_id,
            compact_id=False,
        )
        for triples in triples_groups
    ]


# Traceback (ValueError)
ValueError                                Traceback (most recent call last)
<ipython-input-13-ef15ccdc9011> in <module>
3
4 tf = TriplesFactory(path=work_path + '/eucalyptus_triplets.txt')
----> 5 training, testing = tf.split()
6
7 pipeline_result = pipeline(

~\anaconda3\envs\pykeen\lib\site-packages\pykeen\triples\triples_factory.py in split(self, ratios, random_state, randomize_cleanup)
419         idx = np.arange(n_triples)
420         if random_state is None:
--> 421             random_state = np.random.randint(0, 2 ** 32 - 1)
422             logger.warning(f'Using random_state={random_state} to split {self}')
423         if isinstance(random_state, int):

mtrand.pyx in numpy.random.mtrand.RandomState.randint()

_bounded_integers.pyx in numpy.random._bounded_integers._rand_int32()

ValueError: high is out of bounds for int32

# Fixed code
def split(
    self,
    ratios: Union[float, Sequence[float]] = 0.8,
    *,
    random_state: Union[None, int, np.random.RandomState] = None,
    randomize_cleanup: bool = False,
) -> List["TriplesFactory"]:
    """Split a triples factory into a train/test.

    :param ratios: There are three options for this argument. First, a float can be given between 0 and 1.0,
     non-inclusive. The first triples factory will get this ratio and the second will get the rest. Second,
     a list of ratios can be given for which factory in which order should get what ratios as in ``[0.8, 0.1]``.
     The final ratio can be omitted because that can be calculated. Third, all ratios can be explicitly set in
     order such as in ``[0.8, 0.1, 0.1]`` where the sum of all ratios is 1.0.
    :param random_state: The random state used to shuffle and split the triples in this factory.
    :param randomize_cleanup: If true, uses the non-deterministic method for moving triples to the training set.
     This has the advantage that it doesn't necessarily have to move all of them, but it might be slower.

    .. code-block:: python

        ratio = 0.8  # makes a [0.8, 0.2] split
        training_factory, testing_factory = factory.split(ratio)

        ratios = [0.8, 0.1]  # makes a [0.8, 0.1, 0.1] split
        training_factory, testing_factory, validation_factory = factory.split(ratios)

        ratios = [0.8, 0.1, 0.1]  # also makes a [0.8, 0.1, 0.1] split
        training_factory, testing_factory, validation_factory = factory.split(ratios)
    """
    n_triples = self.triples.shape[0]

    # Prepare shuffle index
    idx = np.arange(n_triples)
    if random_state is None:
        random_state = random_non_negative_int()
        logger.warning(f"Using random_state={random_state} to split {self}")
    if isinstance(random_state, int):
        random_state = np.random.RandomState(random_state)
    random_state.shuffle(idx)

    # Prepare split index
    if isinstance(ratios, float):
        ratios = [ratios]

    ratio_sum = sum(ratios)
    if ratio_sum == 1.0:
        ratios = ratios[:-1]  # vsplit doesn't take the final number into account.
    elif ratio_sum > 1.0:
        raise ValueError(f"ratios sum to more than 1.0: {ratios} (sum={ratio_sum})")

    sizes = [int(split_ratio * n_triples) for split_ratio in ratios]
    # Take cumulative sum so the get separated properly
    split_idxs = np.cumsum(sizes)

    # Split triples
    triples_groups = np.vsplit(self.triples[idx], split_idxs)
    logger.info(
        f"split triples to groups of sizes {[triples.shape[0] for triples in triples_groups]}"
    )

    # Make sure that the first element has all the right stuff in it
    triples_groups = _tf_cleanup_all(
        triples_groups, random_state=random_state if randomize_cleanup else None
    )

    for i, (triples, exp_size, exp_ratio) in enumerate(
        zip(triples_groups, sizes, ratios)
    ):
        actual_size = triples.shape[0]
        actual_ratio = actual_size / exp_size * exp_ratio
        if actual_size != exp_size:
            logger.warning(
                f"Requested ratio[{i}]={exp_ratio:.3f} (equal to size {exp_size}), but got {actual_ratio:.3f} "
                f"(equal to size {actual_size}) to ensure that all entities/relations occur in train.",
            )

    # Make new triples factories for each group
    return [
        TriplesFactory(
            triples=triples,
            entity_to_id=self.entity_to_id,
            relation_to_id=self.relation_to_id,
            compact_id=False,
        )
        for triples in triples_groups
    ]