We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 01ba317 commit dac7e8eCopy full SHA for dac7e8e
pygmt/clib/conversion.py
@@ -2,6 +2,7 @@
2
Functions to convert data types into ctypes friendly formats.
3
"""
4
5
+import contextlib
6
import ctypes as ctp
7
import warnings
8
from collections.abc import Sequence
@@ -178,6 +179,11 @@ def _to_numpy(data: Any) -> np.ndarray:
178
179
else:
180
vec_dtype = str(getattr(data, "dtype", ""))
181
array = np.ascontiguousarray(data, dtype=dtypes.get(vec_dtype))
182
+
183
+ # Check if a np.object_ array can be converted to np.str_.
184
+ if array.dtype == np.object_:
185
+ with contextlib.suppress(TypeError, ValueError):
186
+ return np.ascontiguousarray(array, dtype=np.str_)
187
return array
188
189
0 commit comments