NVIDIA / NVIDIA/cudf

[BUG] `pylibcudf.Column.from_iterable_of_py(<nested_list>, dtype=plc.TypeId.LIST)` erroneously raises

Open
#21,092 0 comments 1 reaction 0 assignees View on GitHub
bug pylibcudf
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Steps/Code to reproduce bug**
```python
In [1]: import pylibcudf as plc

In [2]: plc.Column.from_iterable_of_py([[1, 2, 3]]) # works
Out[2]:

In [3]: plc.Column.from_iterable_of_py([[1, 2, 3]], dtype=plc.DataType(plc.TypeId.LIST))
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/cudf/python/pylibcudf/pylibcudf/types.pyx:151, in pylibcudf.types.DataType._python_typecode.__get__()

KeyError:

During handling of the above exception, another exception occurred:

NotImplementedError Traceback (most recent call last)
Cell In[3], line 1
----> 1 plc.Column.from_iterable_of_py([[1, 2, 3]], dtype=plc.DataType(plc.TypeId.LIST))

File ~/cudf/python/pylibcudf/pylibcudf/column.pyx:1238, in pylibcudf.column.Column.from_iterable_of_py()

File ~/cudf/python/pylibcudf/pylibcudf/types.pyx:153, in pylibcudf.types.DataType._python_typecode.__get__()

NotImplementedError: No Python typecode for DataType
```

I believe here we should still be "flattening" and inferring the inner type in the `else` clause if a `plc.DataType(plc.TypeId.LIST)` is passed

```python
if dtype is None:
depth, py_dtype = _infer_list_depth_and_dtype(obj)
dtype = DataType.from_py(py_dtype)
else:
depth, _ = _infer_list_depth_and_dtype(obj)
```

**Expected behavior**
Same as `Out[2]`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.