Skip to content

Commit dbc8ded

Browse files
weiji14seisman
andcommitted
Use virtualfile_from_matrix on int/uint/float types and add a test
Co-Authored-By: Dongdong Tian <[email protected]>
1 parent 5c24f23 commit dbc8ded

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

pygmt/clib/session.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ def virtualfile_from_data(
13801380
raster grid, a vector matrix/arrays, or other supported data input.
13811381
x/y/z : 1d arrays or None
13821382
x, y and z columns as numpy arrays.
1383-
extra_arrays : list
1383+
extra_arrays : list of 1d arrays
13841384
Optional. A list of numpy arrays in addition to x, y and z. All
13851385
of these arrays must be of the same size as the x/y/z arrays.
13861386
@@ -1446,9 +1446,10 @@ def virtualfile_from_data(
14461446
_data = [array for _, array in data.items()]
14471447
except AttributeError:
14481448
try:
1449-
# Just use virtualfile_from_matrix for 2D
1450-
# numpy.ndarray which are not datetime (M) types
1451-
assert data.ndim == 2 and not data.dtype.kind == "M"
1449+
# Just use virtualfile_from_matrix for 2D numpy.ndarray
1450+
# which are signed integer (i), unsigned integer (u) or
1451+
# floating point (f) types
1452+
assert data.ndim == 2 and data.dtype.kind in "iuf"
14521453
_virtualfile_from = self.virtualfile_from_matrix
14531454
_data = (data,)
14541455
except (AssertionError, AttributeError):

pygmt/tests/test_info.py

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def test_info():
2828
)
2929
assert output == expected_output
3030

31+
def test_info_2d_list():
32+
"""
33+
Make sure info works on a 2d list.
34+
"""
35+
output = info(table=[[0, 8], [3, 5], [6, 2]])
36+
expected_output = "<vector memory>: N = 3 <0/6> <2/8>\n"
37+
assert output == expected_output
38+
3139

3240
def test_info_dataframe():
3341
"""

0 commit comments

Comments
 (0)