File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
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 ]
13+
1214try :
1315 import pyarrow as pa
16+
17+ StringArrayTypes |= pa .StringArray
1418except ImportError :
1519 pa = None
1620
21+
1722def dataarray_to_matrix (grid ):
1823 """
1924 Transform an xarray.DataArray into a data 2-D array and metadata.
@@ -267,7 +272,7 @@ def sequence_to_ctypes_array(
267272 return (ctype * size )(* sequence )
268273
269274
270- def strings_to_ctypes_array (strings : Sequence [ str ] | pa . StringArray ) -> ctp .Array :
275+ def strings_to_ctypes_array (strings : StringArrayTypes ) -> ctp .Array :
271276 """
272277 Convert a sequence (e.g., a list) of strings or a pyarrow.StringArray into a ctypes
273278 array.
Original file line number Diff line number Diff line change 3434 tempfile_from_image ,
3535)
3636
37+ StringArrayTypes = Sequence [str ]
38+
3739try :
3840 import pyarrow as pa
41+
42+ StringArrayTypes |= pa .StringArray
3943except ImportError :
4044 pa = None
4145
46+
4247FAMILIES = [
4348 "GMT_IS_DATASET" , # Entity is a data table
4449 "GMT_IS_GRID" , # Entity is a grid
@@ -945,7 +950,7 @@ def put_strings(
945950 self ,
946951 dataset : ctp .c_void_p ,
947952 family : Literal ["GMT_IS_VECTOR" , "GMT_IS_MATRIX" ],
948- strings : Sequence [ str ] | pa . StringArray ,
953+ strings : StringArrayTypes ,
949954 ):
950955 """
951956 Attach a 1-D numpy array of dtype str or pyarrow.StringArray as a column on a
You can’t perform that action at this time.
0 commit comments