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 99import numpy as np
1010from pygmt .exceptions import GMTInvalidInput
1111
12- StringArrayTypes = Sequence [str ]
12+ StringArrayTypes = Sequence [str ] | np . ndarray
1313
1414try :
1515 import pyarrow as pa
@@ -300,7 +300,7 @@ def strings_to_ctypes_array(strings: StringArrayTypes) -> ctp.Array:
300300 bytes_string_list = [s .encode () for s in strings ]
301301 except AttributeError : # 'pyarrow.StringScalar' object has no attribute 'encode'
302302 # 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]
304304 return (ctp .c_char_p * len (strings ))(* bytes_string_list )
305305
306306
Original file line number Diff line number Diff line change 3434 tempfile_from_image ,
3535)
3636
37- StringArrayTypes = Sequence [str ]
37+ StringArrayTypes = Sequence [str ] | np . ndarray
3838
3939try :
4040 import pyarrow as pa
@@ -1005,9 +1005,8 @@ def put_strings(
10051005 self .session_pointer , family_int , dataset , strings_pointer
10061006 )
10071007 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" )
10111010
10121011 def put_matrix (self , dataset , matrix , pad = 0 ):
10131012 """
You can’t perform that action at this time.
0 commit comments