# Buggy code
def main(
    path: str,
    directory: str,
    test_ratios,
    no_validation: bool,
    validation_ratios,
    reload,
    seed,
):
    """Make a dataset from the given triples."""
    os.makedirs(directory, exist_ok=True)

    triples_factory = TriplesFactory(path=path)
    ratios = test_ratios if no_validation else validation_ratios

    if seed is None:
        seed = np.random.randint(0, 2**32 - 1)
    sub_triples_factories = triples_factory.split(ratios, random_state=seed)

    for subset_name, subset_tf in zip(LABELS, sub_triples_factories):
        output_path = os.path.join(directory, f"{subset_name}.txt")
        click.echo(f"Outputing {subset_name} to {output_path}")
        np.savetxt(output_path, subset_tf.triples, delimiter="\t", fmt="%s")

    metadata = dict(
        source=os.path.abspath(path),
        ratios=dict(zip(LABELS, ratios)),
        seed=seed,
    )
    with open(os.path.join(directory, "metadata.json"), "w") as file:
        json.dump(metadata, file, indent=2)

    if reload:
        if no_validation:
            click.secho(
                "Can not load as dataset if --no-validation was flagged.", fg="red"
            )
            return
        d = PathDataSet(
            training_path=os.path.join(directory, "train.txt"),
            testing_path=os.path.join(directory, "test.txt"),
            validation_path=os.path.join(directory, "valid.txt"),
            eager=True,
        )
        print(d)


# 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 main(
    path: str,
    directory: str,
    test_ratios,
    no_validation: bool,
    validation_ratios,
    reload,
    seed,
):
    """Make a dataset from the given triples."""
    os.makedirs(directory, exist_ok=True)

    triples_factory = TriplesFactory(path=path)
    ratios = test_ratios if no_validation else validation_ratios

    if seed is None:
        seed = random_non_negative_int()
    sub_triples_factories = triples_factory.split(ratios, random_state=seed)

    for subset_name, subset_tf in zip(LABELS, sub_triples_factories):
        output_path = os.path.join(directory, f"{subset_name}.txt")
        click.echo(f"Outputing {subset_name} to {output_path}")
        np.savetxt(output_path, subset_tf.triples, delimiter="\t", fmt="%s")

    metadata = dict(
        source=os.path.abspath(path),
        ratios=dict(zip(LABELS, ratios)),
        seed=seed,
    )
    with open(os.path.join(directory, "metadata.json"), "w") as file:
        json.dump(metadata, file, indent=2)

    if reload:
        if no_validation:
            click.secho(
                "Can not load as dataset if --no-validation was flagged.", fg="red"
            )
            return
        d = PathDataSet(
            training_path=os.path.join(directory, "train.txt"),
            testing_path=os.path.join(directory, "test.txt"),
            validation_path=os.path.join(directory, "valid.txt"),
            eager=True,
        )
        print(d)