Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Oct 11, 2024
1 parent ebaa562 commit e100e2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions python/cudf/cudf/testing/dataset_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ def rand_dataframe(
),
is_sorted=False,
dtype=dtype,
rng=rng,
)
)
elif dtype == "struct":
Expand Down Expand Up @@ -794,6 +793,7 @@ def get_nested_lists(dtype, size, nesting_depth, lists_max_length, rng):
lists_max_length=lists_max_length,
nesting_depth=nesting_depth,
top_level_list=[],
rng=rng,
)
)

Expand Down Expand Up @@ -870,7 +870,7 @@ def create_nested_struct_type(max_types_at_each_level, nesting_level, rng):


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


def _unique_string() -> str:
Expand Down
10 changes: 8 additions & 2 deletions python/cudf/cudf/tests/test_factorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def test_factorize_series_obj(ncats, nelem):
df["cats"] = arr = rng.integers(2, size=10, dtype=np.int32)

uvals, labels = df["cats"].factorize()
np.testing.assert_array_equal(labels.to_numpy(), sorted(set(arr)))
unique_values, indices = np.unique(arr, return_index=True)
expected_values = unique_values[np.argsort(indices)]

np.testing.assert_array_equal(labels.to_numpy(), expected_values)
assert isinstance(uvals, cp.ndarray)
assert isinstance(labels, Index)

Expand All @@ -38,7 +41,10 @@ def test_factorize_index_obj(ncats, nelem):
df = df.set_index("cats")

uvals, labels = df.index.factorize()
np.testing.assert_array_equal(labels.values.get(), sorted(set(arr)))
unique_values, indices = np.unique(arr, return_index=True)
expected_values = unique_values[np.argsort(indices)]

np.testing.assert_array_equal(labels.values.get(), expected_values)
assert isinstance(uvals, cp.ndarray)
assert isinstance(labels, Index)

Expand Down

0 comments on commit e100e2d

Please sign in to comment.