clib.conversion._to_numpy: Add tests for pyarrow.array with pyarrow numeric types#3599
clib.conversion._to_numpy: Add tests for pyarrow.array with pyarrow numeric types#3599
Conversation
|
I'm not sure why the Python 3.10 job keeps failing on macOS. |
pygmt/tests/test_clib_to_numpy.py
Outdated
| # PyArrow provides the following dtypes: | ||
| # | ||
| # - Numeric dtypes: |
There was a problem hiding this comment.
Minor detail, but PyArrow calls them types instead of dtypes, e.g. at https://arrow.apache.org/docs/python/data.html#type-metadata. So should we call them types instead of dtypes?
| # PyArrow provides the following dtypes: | |
| # | |
| # - Numeric dtypes: | |
| # PyArrow provides the following types: | |
| # | |
| # - Numeric types: |
There was a problem hiding this comment.
Yes, I also noticed the difference. I'm OK with using type in the comments, but for the tests, currently, the test name is:
test_to_numpy_pyarrow_array_pyarrow_dtypes_numeric(dtype, expected_dtype):
Strictly speaking, it should be:
test_to_numpy_pyarrow_array_pyarrow_types_numeric(type, expected_type):
But I feel the minor changes in the tests are unnecessary.
There was a problem hiding this comment.
Yeah, I think they use 'type' in the comments, but use 'dtype' in the function name to be consistent with the other unit tests.
There was a problem hiding this comment.
OK, in 111738c, I've updated 'dtype' to 'type' for comments about PyArrow and left the tests unchanged.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Description of proposed changes
This PR adds tests for
_to_numpyto check if it works for PyArrow arrays with pyarrow numeric dtypes.PyArrow provides 11 numeric dtypes (https://arrow.apache.org/docs/python/api/datatypes.html): int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, and float64. All can be converted to numpy dtype without issues.
Here is a minimal example to play with pyarrow types.
Please note that
pa.float16needs special handling: