-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, in 111738c, I've updated 'dtype' to 'type' for comments about PyArrow and left the tests unchanged.
Description of proposed changes
This PR adds tests for
_to_numpy
to 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.float16
needs special handling: