Skip to content

Commit

Permalink
clib.conversion._to_numpy: Add tests for pyarrow.array with pyarrow s…
Browse files Browse the repository at this point in the history
…tring/large_string/string_view types (#3608)
  • Loading branch information
seisman authored Nov 15, 2024
1 parent 4d2f8cb commit c07f1b6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pygmt/tests/test_clib_to_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_to_numpy_pandas_series_pyarrow_dtypes_date(dtype, expected_dtype):
# - int8, int16, int32, int64
# - uint8, uint16, uint32, uint64
# - float16, float32, float64
# - String types: string/utf8, large_string/large_utf8, string_view
# - Date types:
# - date32[day]
# - date64[ms]
Expand Down Expand Up @@ -278,6 +279,28 @@ def test_to_numpy_pyarrow_array_pyarrow_dtypes_numeric_with_na(dtype, expected_d
npt.assert_array_equal(result, array)


@pytest.mark.skipif(not _HAS_PYARROW, reason="pyarrow is not installed")
@pytest.mark.parametrize(
"dtype",
[
None,
"string",
"utf8", # alias for string
"large_string",
"large_utf8", # alias for large_string
"string_view",
],
)
def test_to_numpy_pyarrow_array_pyarrow_dtypes_string(dtype):
"""
Test the _to_numpy function with PyArrow arrays of PyArrow string types.
"""
array = pa.array(["abc", "defg", "12345"], type=dtype)
result = _to_numpy(array)
_check_result(result, np.str_)
npt.assert_array_equal(result, array)


@pytest.mark.skipif(not _HAS_PYARROW, reason="pyarrow is not installed")
@pytest.mark.parametrize(
("dtype", "expected_dtype"),
Expand Down

0 comments on commit c07f1b6

Please sign in to comment.