Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ def _to_numpy(data: Any) -> np.ndarray:
array
The C contiguous NumPy array.
"""
# Mapping of unsupported dtypes to the expected NumPy dtype.
dtypes: dict[str, str | type] = {
# Mapping of unsupported dtypes to expected NumPy dtypes.
dtypes: dict[str, type | str] = {
# For string dtypes.
"large_string": np.str_, # pa.large_string and pa.large_utf8
"string": np.str_, # pa.string and pa.utf8
"string_view": np.str_, # pa.string_view
# For datetime dtypes.
"date32[day][pyarrow]": "datetime64[D]",
"date64[ms][pyarrow]": "datetime64[ms]",
}
Expand All @@ -173,7 +178,7 @@ def _to_numpy(data: Any) -> np.ndarray:
# we can remove the workaround in PyGMT v0.17.0.
array = np.ascontiguousarray(data.astype(float))
else:
vec_dtype = str(getattr(data, "dtype", ""))
vec_dtype = str(getattr(data, "dtype", getattr(data, "type", "")))
array = np.ascontiguousarray(data, dtype=dtypes.get(vec_dtype))
return array

Expand Down
Loading