jorisvandenbossche commented on code in PR #14238:
URL: https://github.com/apache/arrow/pull/14238#discussion_r983362684
##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -925,3 +925,28 @@ def test_empty_take():
result = empty_arr.take(pa.array([], pa.int32()))
assert len(result) == 0
assert result.equals(empty_arr)
+
+
+class LabelType(pa.ExtensionType):
+
+ def __init__(self):
+ super(LabelType, self).__init__(pa.string(), "label")
+
+ def __arrow_ext_serialize__(self):
+ return b""
+
+ @classmethod
+ def __arrow_ext_deserialize__(cls, storage_type, serialized):
+ return LabelType()
+
[email protected]("data,ty", (
+ ([1, 2, 3], IntegerType),
+ (["cat", "dog", "horse"], LabelType)
+))
+def test_extension_array_to_numpy(data, ty):
+ storage = pa.array(data)
+ ext_arr = pa.ExtensionArray.from_storage(ty(), storage)
+ offsets = pa.array([0, 1])
+ list_arr = pa.ListArray.from_arrays(offsets, ext_arr)
+ list_arr.to_numpy(zero_copy_only=False)
Review Comment:
Can you also test `to_pandas()` in addition to `to_numpy` ?
(and maybe also verify the result, you could construct the expected result
from a ListArray with the storage type instead of extension type)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]