We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 988746b commit 243b488Copy full SHA for 243b488
pygmt/clib/conversion.py
@@ -307,6 +307,13 @@ def strings_to_ctypes_array(strings: Sequence[str] | np.ndarray) -> ctp.Array:
307
<class 'pygmt.clib.conversion.c_char_p_Array_3'>
308
>>> [s.decode() for s in ctypes_array]
309
['first', 'second', 'third']
310
+
311
+ >>> strings = np.array(["first", "second", "third"])
312
+ >>> ctypes_array = strings_to_ctypes_array(strings)
313
+ >>> type(ctypes_array)
314
+ <class 'pygmt.clib.conversion.c_char_p_Array_3'>
315
+ >>> [s.decode() for s in ctypes_array]
316
+ ['first', 'second', 'third']
317
"""
318
return (ctp.c_char_p * len(strings))(*[s.encode() for s in strings])
319
0 commit comments