@@ -1387,32 +1387,24 @@ def virtualfile_from_data(self, check_kind=None, data=None, x=None, y=None, z=No
1387
1387
"""
1388
1388
kind = data_kind (check_kind , data , x , y , z )
1389
1389
1390
- # Decide which virtualfile_from_ function to use
1391
- _virtualfile_from = {
1392
- "file" : dummy_context ,
1393
- "grid" : self .virtualfile_from_grid ,
1394
- # Note: virtualfile_from_matrix is not used because a matrix can be
1395
- # converted to vectors instead, and using vectors allows for better
1396
- # handling of string type inputs (e.g. for datetime data types)
1397
- "matrix" : self .virtualfile_from_vectors ,
1398
- "vectors" : self .virtualfile_from_vectors ,
1399
- }[kind ]
1400
-
1401
- # Ensure the data is an iterable (Python list or tuple)
1402
1390
if kind == "matrix" : # turn 2D arrays into list of vectors
1403
1391
try :
1404
1392
# pandas.DataFrame and xarray.Dataset types
1405
1393
_data = [array for _ , array in data .items ()]
1406
1394
except AttributeError :
1407
1395
# Python lists, tuples, and numpy ndarray types
1408
1396
_data = np .atleast_2d (np .asanyarray (data ).T )
1409
- elif kind == "vectors" :
1410
- _data = (x , y , z )
1411
- else :
1412
- _data = (data ,)
1413
1397
1414
- # Finally create the virtualfile from the data, to be passed into GMT
1415
- file_context = _virtualfile_from (* _data )
1398
+ # Based on the data kind, create the virtualfile to be passed into GMT
1399
+ file_context = {
1400
+ "file" : dummy_context (data ),
1401
+ "grid" : self .virtualfile_from_grid (data ),
1402
+ # Note: virtualfile_from_matrix is not used because a matrix can be
1403
+ # converted to vectors instead, and using vectors allows for better
1404
+ # handling of string type inputs (e.g. for datetime data types)
1405
+ "matrix" : self .virtualfile_from_vectors (* _data ),
1406
+ "vectors" : self .virtualfile_from_vectors (x , y , z ),
1407
+ }[kind ]
1416
1408
1417
1409
return file_context
1418
1410
0 commit comments