@@ -197,26 +197,25 @@ def x2sys_cross(
197
197
198
198
file_contexts = []
199
199
for track in tracks :
200
- kind = data_kind (track )
201
- if kind == "file" :
202
- file_contexts .append (contextlib .nullcontext (track ))
203
- elif kind == "matrix" :
204
- # find suffix (-E) of trackfiles used (e.g. xyz, csv, etc) from
205
- # $X2SYS_HOME/TAGNAME/TAGNAME.tag file
206
- lastline = (
207
- Path (os .environ ["X2SYS_HOME" ], kwargs ["T" ], f"{ kwargs ['T' ]} .tag" )
208
- .read_text (encoding = "utf8" )
209
- .strip ()
210
- .split ("\n " )[- 1 ]
211
- ) # e.g. "-Dxyz -Etsv -I1/1"
212
- for item in sorted (lastline .split ()): # sort list alphabetically
213
- if item .startswith (("-E" , "-D" )): # prefer -Etsv over -Dxyz
214
- suffix = item [2 :] # e.g. tsv (1st choice) or xyz (2nd choice)
215
-
216
- # Save pandas.DataFrame track data to temporary file
217
- file_contexts .append (tempfile_from_dftrack (track = track , suffix = suffix ))
218
- else :
219
- raise GMTInvalidInput (f"Unrecognized data type: { type (track )} " )
200
+ match data_kind (track ):
201
+ case "file" :
202
+ file_contexts .append (contextlib .nullcontext (track ))
203
+ case "matrix" :
204
+ # find suffix (-E) of trackfiles used (e.g. xyz, csv, etc) from
205
+ # $X2SYS_HOME/TAGNAME/TAGNAME.tag file
206
+ tagfile = Path (
207
+ os .environ ["X2SYS_HOME" ], kwargs ["T" ], f"{ kwargs ['T' ]} .tag"
208
+ )
209
+ # Last line is like "-Dxyz -Etsv -I1/1"
210
+ lastline = tagfile .read_text ().splitlines ()[- 1 ]
211
+ for item in sorted (lastline .split ()): # sort list alphabetically
212
+ if item .startswith (("-E" , "-D" )): # prefer -Etsv over -Dxyz
213
+ suffix = item [2 :] # e.g. tsv (1st choice) or xyz (2nd choice)
214
+
215
+ # Save pandas.DataFrame track data to temporary file
216
+ file_contexts .append (tempfile_from_dftrack (track = track , suffix = suffix ))
217
+ case _:
218
+ raise GMTInvalidInput (f"Unrecognized data type: { type (track )} " )
220
219
221
220
with Session () as lib :
222
221
with lib .virtualfile_out (kind = "dataset" , fname = outfile ) as vouttbl :
0 commit comments