Skip to content

Commit 84fedf0

Browse files
committed
clib.conversion._to_numpy: Add tests for panda.Series with pyarrow date32/date64 types
1 parent 189f376 commit 84fedf0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pygmt/tests/test_clib_to_numpy.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ def test_to_numpy_pandas_series_numpy_dtypes_numeric(dtype, expected_dtype):
161161
npt.assert_array_equal(result, series)
162162

163163

164+
@pytest.mark.skipif(not _HAS_PYARROW, reason="pyarrow is not installed")
165+
@pytest.mark.parametrize(
166+
("dtype", "expected_dtype"),
167+
[
168+
pytest.param("date32[day][pyarrow]", "datetime64[D]", id="date32[day]"),
169+
pytest.param("date64[ms][pyarrow]", "datetime64[ms]", id="date64[ms]"),
170+
],
171+
)
172+
def test_to_numpy_pandas_series_pyarrow_dtypes_date(dtype, expected_dtype):
173+
"""
174+
Test the _to_numpy function with pandas.Series of PyArrow date32/date64 types.
175+
"""
176+
series = pd.Series(pd.date_range(start="2024-01-01", periods=3), dtype=dtype)
177+
result = _to_numpy(series)
178+
_check_result(result, np.datetime64)
179+
npt.assert_array_equal(
180+
result,
181+
np.array(["2024-01-01", "2024-01-02", "2024-01-03"], dtype=expected_dtype),
182+
strict=True,
183+
)
184+
185+
164186
########################################################################################
165187
# Test the _to_numpy function with PyArrow arrays.
166188
#

0 commit comments

Comments
 (0)