Skip to content

Commit

Permalink
Error on ListColumn in cudf.Index
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Oct 11, 2022
1 parent 26f3e76 commit a85286e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def _index_from_data(data: MutableMapping, name: Any = None):
index_class_type = CategoricalIndex
elif isinstance(values, (IntervalColumn, StructColumn)):
index_class_type = IntervalIndex
else:
raise NotImplementedError(
"Unsupported column type passed to "
f"create an Index: {type(values)}"
)
else:
index_class_type = cudf.MultiIndex
return index_class_type._from_data(data, name)
Expand Down
12 changes: 12 additions & 0 deletions python/cudf/cudf/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2783,3 +2783,15 @@ def test_index_null_values():
gidx = cudf.Index([1.0, None, 3, 0, None])
with pytest.raises(ValueError):
gidx.values


def test_index_error_list_index():
s = cudf.Series([[1, 2], [2], [4]])
with pytest.raises(
NotImplementedError,
match=re.escape(
"Unsupported column type passed to create an "
"Index: <class 'cudf.core.column.lists.ListColumn'>"
),
):
cudf.Index(s)

0 comments on commit a85286e

Please sign in to comment.