Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll our own generate_string() because mimesis' has gone away #13257

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions python/cudf/cudf/testing/dataset_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION.
# Copyright (c) 2020-2023, NVIDIA CORPORATION.

# This module is for generating "synthetic" datasets. It was originally
# designed for testing filtered reading. Generally, it should be useful
Expand All @@ -8,6 +8,7 @@
import copy
import random
import string
import uuid
from multiprocessing import Pool

import mimesis
Expand Down Expand Up @@ -457,8 +458,7 @@ def rand_dataframe(
cardinality=cardinality,
null_frequency=null_frequency,
generator=lambda cardinality=cardinality: [
mimesis.random.random.randstr(unique=True, length=2000)
for _ in range(cardinality)
_unique_string() for _ in range(cardinality)
],
is_sorted=False,
dtype="category",
Expand Down Expand Up @@ -502,7 +502,7 @@ def rand_dataframe(
cardinality=cardinality,
null_frequency=null_frequency,
generator=lambda cardinality=cardinality: [
mimesis.random.random.generate_string(
_generate_string(
string.printable,
np.random.randint(
low=0,
Expand Down Expand Up @@ -684,7 +684,7 @@ def get_values_for_nested_data(dtype, lists_max_length=None, size=None):
values = float_generator(dtype=dtype, size=cardinality)()
elif dtype.kind in ("U", "O"):
values = [
mimesis.random.random.generate_string(
_generate_string(
string.printable,
100,
)
Expand Down Expand Up @@ -847,3 +847,11 @@ def create_nested_struct_type(max_types_at_each_level, nesting_level):
else:
type_dict[str(name)] = cudf.dtype(type_)
return cudf.StructDtype(type_dict)


def _generate_string(str_seq: str, length: int = 10) -> str:
return "".join(random.choices(str_seq, k=length))


def _unique_string() -> str:
return str(uuid.uuid4()).replace("-", "")