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

Remove hangs from trying to construct un-bounded sequences #13799

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import builtins
import pickle
import warnings
from collections import abc
from functools import cached_property
from itertools import chain
from types import SimpleNamespace
Expand Down Expand Up @@ -2384,12 +2385,16 @@ def as_column(
return cudf.core.column.ListColumn.from_sequences(
arbitrary
)
else:
elif isinstance(arbitrary, abc.Iterable) or isinstance(
arbitrary, abc.Sequence
):
data = as_column(
_construct_array(arbitrary, dtype),
dtype=dtype,
nan_as_null=nan_as_null,
)
else:
raise e
return data


Expand Down
9 changes: 9 additions & 0 deletions python/cudf/cudf/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,3 +2204,12 @@ def test_series_contains(data, index):
assert_eq(10 in ps, 10 in gs)
assert_eq(True in ps, True in gs)
assert_eq(False in ps, False in gs)


def test_series_constructor_unbounded_sequence():
class A:
def __getitem__(self, key):
return 1

with pytest.raises(TypeError):
cudf.Series(A())