You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/06/21 12:53:37 UTC
[GitHub] [arrow] sjperkins opened a new pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
sjperkins opened a new pull request #10565:
URL: https://github.com/apache/arrow/pull/10565
https://github.com/apache/arrow/pull/10452 contains the PR implemented Complex Numbers as First Class Types
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-999636230
Thanks for checking in @jmdeschenes. I'm still working on it, but I haven't been able to give it attention recently. IIRC there are some issues I need to work through.
1. Most standard Numpy data types are First-Class Arrow types and the existing code handles conversion between them. Complex Number Arrow Types are Extension Types so their handling is a bit trickier and I haven't found a clean solution with the existing code, or with newer code that I've written yet.
2. I was very unsure about exposing C++ Extension Types in Python mostly because working in the CPython layer is slower and more opaque. It seems you've pointed out the reverse issue, in that Python Extension Types are stripped out during conversion to the C++ layer.
Any advice/help on the above 2 issues would be welcome. Note that I will likely only get another chance to look at this next year.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jmdeschenes commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jmdeschenes commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-999702255
Thanks for the update.
With some changes, I was able to get it your branch to work and output a complex array. It is still preliminary. Let me know if you want to see it.
I think the best way forward is to let the CPP handle the extension types.
1. Don't strip the Extension information on the Cython side
2. CPP could handle future extension types each with their own potential `Writer`. Instead of stripping the Extension information on the cython side, let the CPP handle it(e.g. if the extension is known, use the Writer, if it doesn't, use the storage). This will require some rewrite on the CPP side as the extension type is used in the conversion code but I don't understand when it applies. To me this looks like the least intrusive option.
fixed_list_size_arrays generate a numpy array of pyarrow arrays. If fixed_list_size were to yield a 2D numpy array(which is directly mappable) there would be little needs for the extension side being handled at all. I guess this was done to ensure that the columns could be read into pandas. When calling `to_numpy` I would expect to get a 2D array.
As a separate issue, When trying to handle complex arrays from the python side only using extension arrays. It mostly works but the extension arrays don't play nice with ChunkedArrays
```python
import pyarrow as pa
import pyarrow.parquet as pq
import numpy as np
class ComplexArray(pa.ExtensionArray):
def to_numpy(self):
array = self.storage.flatten().to_numpy(zero_copy_only=True).view('complex128')
return array
class ComplexType(pa.ExtensionType):
def __init__(self):
pa.ExtensionType.__init__(self, pa.list_(pa.float64(), 2), "arrow.complex128")
def __arrow_ext_serialize__(self):
# since we don't have a parameterized type, we don't need extra
# metadata to be deserialized
return b''
@classmethod
def __arrow_ext_deserialize__(self, storage_type, serialized):
# return an instance of this subclass given the serialized
# metadata.
return ComplexType()
def __arrow_ext_class__(self):
return ComplexArray
complex128 = ComplexType()
pa.register_extension_type(complex128)
array = np.array([1.0+1j, 2.0+2.0j, 3.0+3.0j]).view('float64')
float_array = pa.array(array, type=pa.float64())
list_array = pa.FixedSizeListArray.from_arrays(float_array, 2)
pa_array = ComplexArray.from_storage(complex128, list_array)
# This will yield the correct Numpy Array
assert (pa_array.to_numpy() == array).all()
```
It works but we get into issues when writing/reading from parquet
```python
table = pa.Table.from_arrays([pa_array], names=['cpl'])
pq.write_table(table, "complex_test.parquet")
cpl_df = pq.read_table("complex_test.parquet")
# This line will create a numpy array of pyarrow arrays
cpl_df['cpl'].to_numpy()
# If you have a single chunk, this will work
assert (cpl_df['cpl'].chunks[0].to_numpy() == array).all()
# Otherwise the solution is more involved
start_length = 0
end_length = 0
max_length = cpl_df['cpl'].length()
final_numpy = np.zeros(shape=(max_length), dtype=np.complex128)
for chunk in cpl_df['cpl'].iterchunks():
temp_numpy = chunk.to_numpy()
end_length += temp_numpy.shape[0]
final_numpy[start_length:end_length] = temp_numpy
start_length = end_length
assert (final_numpy == array).all()
```
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-885786527
The Complex Extension Type now seems to be somewhat understood by the Python layer, but seems to be failing because there's no `__arrow_ext_class__` attribute, which seems to be [required ](https://arrow.apache.org/docs/python/extending_types.html )by the Python layer
https://github.com/sjperkins/arrow/runs/3144270259?check_suite_focus=true#step:8:9416
```traceback
Traceback (most recent call last):
File "/opt/conda/envs/arrow/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/tests/test_pandas.py", line 2533, in _threaded_conversion
_check_pandas_roundtrip(df, use_threads=True)
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/tests/test_pandas.py", line 91, in _check_pandas_roundtrip
nthreads=2 if use_threads else 1)
File "pyarrow/table.pxi", line 1561, in pyarrow.lib.Table.from_pandas
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/pandas_compat.py", line 607, in dataframe_to_arrays
arrays[i] = maybe_fut.result()
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/pandas_compat.py", line 575, in convert_column
result = pa.array(col, type=type_, from_pandas=True, safe=safe)
File "pyarrow/array.pxi", line 302, in pyarrow.lib.array
File "pyarrow/array.pxi", line 89, in pyarrow.lib._ndarray_to_array
File "pyarrow/types.pxi", line 200, in pyarrow.lib.DataType.to_pandas_dtype
File "pyarrow/array.pxi", line 2402, in pyarrow.lib.get_array_class_from_type
AttributeError: 'pyarrow.lib.BaseExtensionType' object has no attribute '__arrow_ext_class__'
```
I **think** this may be happening because of the following lines
https://github.com/apache/arrow/blob/42e5726b543135f18db1560278e062b9a7941f5c/python/pyarrow/public-api.pxi#L110-L116
which are invoked in this location:
https://github.com/apache/arrow/blob/42e5726b543135f18db1560278e062b9a7941f5c/python/pyarrow/array.pxi#L2400-L2402
So at this stage, it doesn't look like the underlying C++ Extension Type is fully exposed in the Python layer. For example, the `__arrow_ext_class__` should return some Python wrapper of the underlying C++ ExtensionArray.
I'd appreciate some guidance at this point on how to achieve this. /cc @pitrou who looks like he may have worked on this last in https://github.com/apache/arrow/pull/4532
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-1000166824
> With some changes, I was able to get it your branch to work and output a complex array. It is still preliminary. Let me know if you want to see it.
Thanks, yes I would like to take a look.
> I think the best way forward is to let the CPP handle the extension types.
>
> 1. Don't strip the Extension information on the Cython side
>
> 2. CPP could handle future extension types each with their own potential `Writer`. Instead of stripping the Extension information on the cython side, let the CPP handle it(e.g. if the extension is known, use the Writer, if it doesn't, use the storage). This will require some rewrite on the CPP side as the extension type is used in the conversion code but I don't understand when it applies. To me this looks like the least intrusive option.
Yes, I agree that this is the way forward. Mirroring what you've described back to you, this will necessitate API changes to the C++ Extension Framework to support Custom Writers?
> fixed_list_size_arrays generate a numpy array of pyarrow arrays. If fixed_list_size were to yield a 2D numpy array(which is directly mappable) there would be little needs for the extension side being handled at all. I guess this was done to ensure that the columns could be read into pandas. When calling `to_numpy` I would expect to get a 2D array.
>
> As a separate issue, When trying to handle complex arrays from the python side only using extension arrays. It mostly works but the extension arrays don't play nice with ChunkedArrays
>
> ```python
> import pyarrow as pa
> import pyarrow.parquet as pq
> import numpy as np
>
> class ComplexArray(pa.ExtensionArray):
> def to_numpy(self):
> array = self.storage.flatten().to_numpy(zero_copy_only=True).view('complex128')
> return array
>
> class ComplexType(pa.ExtensionType):
> def __init__(self):
> pa.ExtensionType.__init__(self, pa.list_(pa.float64(), 2), "arrow.complex128")
> def __arrow_ext_serialize__(self):
> # since we don't have a parameterized type, we don't need extra
> # metadata to be deserialized
> return b''
> @classmethod
> def __arrow_ext_deserialize__(self, storage_type, serialized):
> # return an instance of this subclass given the serialized
> # metadata.
> return ComplexType()
> def __arrow_ext_class__(self):
> return ComplexArray
>
> complex128 = ComplexType()
> pa.register_extension_type(complex128)
>
> array = np.array([1.0+1j, 2.0+2.0j, 3.0+3.0j]).view('float64')
> float_array = pa.array(array, type=pa.float64())
> list_array = pa.FixedSizeListArray.from_arrays(float_array, 2)
> pa_array = ComplexArray.from_storage(complex128, list_array)
> # This will yield the correct Numpy Array
> assert (pa_array.to_numpy() == array).all()
> ```
>
> It works but we get into issues when writing/reading from parquet
>
> ```python
> table = pa.Table.from_arrays([pa_array], names=['cpl'])
> pq.write_table(table, "complex_test.parquet")
> cpl_df = pq.read_table("complex_test.parquet")
> # This line will create a numpy array of pyarrow arrays
> cpl_df['cpl'].to_numpy()
> # If you have a single chunk, this will work
> assert (cpl_df['cpl'].chunks[0].to_numpy() == array).all()
>
> # Otherwise the solution is more involved
> start_length = 0
> end_length = 0
> max_length = cpl_df['cpl'].length()
> final_numpy = np.zeros(shape=(max_length), dtype=np.complex128)
> for chunk in cpl_df['cpl'].iterchunks():
> temp_numpy = chunk.to_numpy()
> end_length += temp_numpy.shape[0]
> final_numpy[start_length:end_length] = temp_numpy
> start_length = end_length
> assert (final_numpy == array).all()
> ```
It does work quite nicely in Python. In fact, I implemented something similar in a repository I'm working on: https://github.com/ska-sa/dask-ms/blob/55c987e5f00c24a82c16363f681a966e45590e06/daskms/experimental/arrow/extension_types.py#L145-L148. IIRC I ran into similar issues with chunked Extension Arrays.
Do you have an idea as to how this should be handled in the C++ layer?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-865008462
https://issues.apache.org/jira/browse/ARROW-638
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jmdeschenes commented on a change in pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jmdeschenes commented on a change in pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#discussion_r773112224
##########
File path: cpp/src/arrow/python/type_traits.h
##########
@@ -334,6 +377,10 @@ static inline int NumPyTypeSize(int npy_type) {
return 4;
case NPY_FLOAT64:
return 8;
+ case NPY_COMPLEX64:
+ return 16;
+ case NPY_COMPLEX128:
+ return 32;
Review comment:
This seems rather strange. Shouldn't it be 8 bytes for `NPY_COMPLEX64` and 16 bytes for `NPY_COMPLEX128`? They should be exactly twice the values for NPY_FLOAT32 and NPY_FLOAT64 respectively.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorisvandenbossche commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-890893166
> e failing because there's no `__arrow_ext_class__` attribute, which seems to be [required ](https://arrow.apache.org/docs/python/extending_types.html)by the Python layer
That might have been an oversight in the PR that introduced it (I don't think we currently have python tests using an extension type that is purely implemented in C++, and not using the (Py)ExtensionType subclassing mechanisms, although we should probably have such tests).
Can you check if moving the `__arrow_ext_class__` base definition at
https://github.com/apache/arrow/blob/c51e4a179379628578a69f536ffca80a844efcd2/python/pyarrow/types.pxi#L776-L784
from the `ExtensionType` class to its parent class `BaseExtensionType`, fixes the problem?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jmdeschenes edited a comment on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jmdeschenes edited a comment on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-999017847
Hello,
There is an issue with the approach:
on array.pxi
```cython
cdef class ExtensionArray(Array):
"""
Concrete class for Arrow extension arrays.
"""
@property
def storage(self):
cdef:
CExtensionArray* ext_array = <CExtensionArray*>(self.ap)
return pyarrow_wrap_array(ext_array.storage())
#
## LINES SKIPPED
#
def to_numpy(self, **kwargs):
"""
Convert extension array to a numpy ndarray.
See Also
--------
Array.to_numpy
"""
return self.storage.to_numpy(**kwargs)
```
on table.pxi
```cython
def to_numpy(self):
"""
Return a NumPy copy of this array (experimental).
Returns
-------
array : numpy.ndarray
"""
cdef:
PyObject* out
PandasOptions c_options
object values
if self.type.id == _Type_EXTENSION:
storage_array = chunked_array(
[chunk.storage for chunk in self.iterchunks()],
type=self.type.storage_type
```
Both of these "strip" the Extension type sent to the CPP code. As such, the CPP code never knows that it is dealing with an extension.
If this is to be kept, fixed_size_list would need to convert into a proper 2D numpy array(That could have several benefits, it could be done only for primitive types at the start)
@jorisvandenbossche Do you think that is something that could be acceptable?
Otherwise, letting the CPP code handle the extension type could be another option.
@sjperkins Are you still working on this PR? Is there something I can help you with?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins commented on a change in pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins commented on a change in pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#discussion_r773941345
##########
File path: cpp/src/arrow/python/type_traits.h
##########
@@ -334,6 +377,10 @@ static inline int NumPyTypeSize(int npy_type) {
return 4;
case NPY_FLOAT64:
return 8;
+ case NPY_COMPLEX64:
+ return 16;
+ case NPY_COMPLEX128:
+ return 32;
Review comment:
Indeed, thanks for catching this, fixed in https://github.com/apache/arrow/pull/10565/commits/e31d556b03f5a8eae31df9a954e9dca8a0f27f14
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-885800385
Perhaps @jorisvandenbossche can answer the previous message, when he's back from vacation :-)
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-1021981985
> With some changes, I was able to get it your branch to work and output a complex array. It is still preliminary. Let me know if you want to see it.
Hi @jmdeschenes, I'll be devoting some time to this PR over the next few weeks. Would it be possible to see your branch?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jmdeschenes commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jmdeschenes commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-999017847
Hello,
There is an issue with the approach:
on array.pxi
```cython
cdef class ExtensionArray(Array):
"""
Concrete class for Arrow extension arrays.
"""
@property
def storage(self):
cdef:
CExtensionArray* ext_array = <CExtensionArray*>(self.ap)
return pyarrow_wrap_array(ext_array.storage())
#
## LINES SKIPPED
#
def to_numpy(self, **kwargs):
"""
Convert extension array to a numpy ndarray.
See Also
--------
Array.to_numpy
"""
return self.storage.to_numpy(**kwargs)
```
on table.pxi
```cython
def to_numpy(self):
"""
Return a NumPy copy of this array (experimental).
Returns
-------
array : numpy.ndarray
"""
cdef:
PyObject* out
PandasOptions c_options
object values
if self.type.id == _Type_EXTENSION:
storage_array = chunked_array(
[chunk.storage for chunk in self.iterchunks()],
type=self.type.storage_type
```
Both of these "strip" the Extension type sent to the CPP code. As such, the CPP code never knows that it is dealing with an extension.
If this is to be kept, fixed_size_list would need to convert into a proper 2D numpy array(That could have several benefits, it could be done only for primitive types at the start)
@jorisvandenbossche Do you think that is something that could be acceptable?
Otherwise, letting the CPP code handle the extension type could be another option.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] sjperkins edited a comment on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
sjperkins edited a comment on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-885786527
The Complex Extension Type now seems to be somewhat understood by the Python layer, but seems to be failing because there's no `__arrow_ext_class__` attribute, which seems to be [required ](https://arrow.apache.org/docs/python/extending_types.html )by the Python layer
https://github.com/sjperkins/arrow/runs/3144270259?check_suite_focus=true#step:8:9416
```traceback
Traceback (most recent call last):
File "/opt/conda/envs/arrow/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/tests/test_pandas.py", line 2533, in _threaded_conversion
_check_pandas_roundtrip(df, use_threads=True)
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/tests/test_pandas.py", line 91, in _check_pandas_roundtrip
nthreads=2 if use_threads else 1)
File "pyarrow/table.pxi", line 1561, in pyarrow.lib.Table.from_pandas
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/pandas_compat.py", line 607, in dataframe_to_arrays
arrays[i] = maybe_fut.result()
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/opt/conda/envs/arrow/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/opt/conda/envs/arrow/lib/python3.7/site-packages/pyarrow/pandas_compat.py", line 575, in convert_column
result = pa.array(col, type=type_, from_pandas=True, safe=safe)
File "pyarrow/array.pxi", line 302, in pyarrow.lib.array
File "pyarrow/array.pxi", line 89, in pyarrow.lib._ndarray_to_array
File "pyarrow/types.pxi", line 200, in pyarrow.lib.DataType.to_pandas_dtype
File "pyarrow/array.pxi", line 2402, in pyarrow.lib.get_array_class_from_type
AttributeError: 'pyarrow.lib.BaseExtensionType' object has no attribute '__arrow_ext_class__'
```
I **think** this may be happening because of the following lines
https://github.com/apache/arrow/blob/42e5726b543135f18db1560278e062b9a7941f5c/python/pyarrow/public-api.pxi#L110-L116
which are invoked in this location:
https://github.com/apache/arrow/blob/42e5726b543135f18db1560278e062b9a7941f5c/python/pyarrow/array.pxi#L2400-L2402
So at this stage, it doesn't look like the underlying C++ Extension Type is fully exposed in the Python layer. For example, `__arrow_ext_class__` should probably return some Python wrapper of the underlying C++ ExtensionArray.
I'd appreciate some guidance at this point on how to achieve this. /cc @pitrou who looks like he may have worked on this last in https://github.com/apache/arrow/pull/4532
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorisvandenbossche edited a comment on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
jorisvandenbossche edited a comment on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-890893166
> failing because there's no `__arrow_ext_class__` attribute, which seems to be [required ](https://arrow.apache.org/docs/python/extending_types.html)by the Python layer
That might have been an oversight in the PR that introduced it (I don't think we currently have python tests using an extension type that is purely implemented in C++, and not using the (Py)ExtensionType subclassing mechanisms, although we should probably have such tests).
Can you check if moving the `__arrow_ext_class__` base definition at
https://github.com/apache/arrow/blob/c51e4a179379628578a69f536ffca80a844efcd2/python/pyarrow/types.pxi#L776-L784
from the `ExtensionType` class to its parent class `BaseExtensionType`, fixes the problem?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10565: ARROW-638: [C++] Complex Number Support via ExtensionTypes
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10565:
URL: https://github.com/apache/arrow/pull/10565#issuecomment-865008462
https://issues.apache.org/jira/browse/ARROW-638
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org