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 9
9
import numpy as np
10
10
from pygmt .exceptions import GMTInvalidInput
11
11
12
+ StringArrayTypes = Sequence [str ]
13
+
12
14
try :
13
15
import pyarrow as pa
16
+
17
+ StringArrayTypes |= pa .StringArray
14
18
except ImportError :
15
19
pa = None
16
20
21
+
17
22
def dataarray_to_matrix (grid ):
18
23
"""
19
24
Transform an xarray.DataArray into a data 2-D array and metadata.
@@ -267,7 +272,7 @@ def sequence_to_ctypes_array(
267
272
return (ctype * size )(* sequence )
268
273
269
274
270
- def strings_to_ctypes_array (strings : Sequence [ str ] | pa . StringArray ) -> ctp .Array :
275
+ def strings_to_ctypes_array (strings : StringArrayTypes ) -> ctp .Array :
271
276
"""
272
277
Convert a sequence (e.g., a list) of strings or a pyarrow.StringArray into a ctypes
273
278
array.
Original file line number Diff line number Diff line change 34
34
tempfile_from_image ,
35
35
)
36
36
37
+ StringArrayTypes = Sequence [str ]
38
+
37
39
try :
38
40
import pyarrow as pa
41
+
42
+ StringArrayTypes |= pa .StringArray
39
43
except ImportError :
40
44
pa = None
41
45
46
+
42
47
FAMILIES = [
43
48
"GMT_IS_DATASET" , # Entity is a data table
44
49
"GMT_IS_GRID" , # Entity is a grid
@@ -945,7 +950,7 @@ def put_strings(
945
950
self ,
946
951
dataset : ctp .c_void_p ,
947
952
family : Literal ["GMT_IS_VECTOR" , "GMT_IS_MATRIX" ],
948
- strings : Sequence [ str ] | pa . StringArray ,
953
+ strings : StringArrayTypes ,
949
954
):
950
955
"""
951
956
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