File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 9
9
import numpy as np
10
10
from pygmt .exceptions import GMTInvalidInput
11
11
12
- StringArrayTypes = Sequence [str ]
12
+ StringArrayTypes = Sequence [str ] | np . ndarray
13
13
14
14
try :
15
15
import pyarrow as pa
@@ -300,7 +300,7 @@ def strings_to_ctypes_array(strings: StringArrayTypes) -> ctp.Array:
300
300
bytes_string_list = [s .encode () for s in strings ]
301
301
except AttributeError : # 'pyarrow.StringScalar' object has no attribute 'encode'
302
302
# Convert pyarrow.StringArray to Python list first
303
- bytes_string_list = [s .encode () for s in strings .to_pylist ()]
303
+ bytes_string_list = [s .encode () for s in strings .to_pylist ()] # type: ignore[union-attr]
304
304
return (ctp .c_char_p * len (strings ))(* bytes_string_list )
305
305
306
306
Original file line number Diff line number Diff line change 34
34
tempfile_from_image ,
35
35
)
36
36
37
- StringArrayTypes = Sequence [str ]
37
+ StringArrayTypes = Sequence [str ] | np . ndarray
38
38
39
39
try :
40
40
import pyarrow as pa
@@ -1005,9 +1005,8 @@ def put_strings(
1005
1005
self .session_pointer , family_int , dataset , strings_pointer
1006
1006
)
1007
1007
if status != 0 :
1008
- raise GMTCLibError (
1009
- f"Failed to put strings of type { strings .dtype } into dataset"
1010
- )
1008
+ dtype = strings .dtype if hasattr (strings , "dtype" ) else type (strings )
1009
+ raise GMTCLibError (f"Failed to put strings of type { dtype } into dataset" )
1011
1010
1012
1011
def put_matrix (self , dataset , matrix , pad = 0 ):
1013
1012
"""
You can’t perform that action at this time.
0 commit comments