Skip to content

Commit 59f326b

Browse files
committed
Fix the logic of checking kinds
1 parent a6b85e2 commit 59f326b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pygmt/clib/session.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1537,16 +1537,16 @@ def virtualfile_from_data(
15371537
data, x, y, z, required_z=required_z, required_data=required_data
15381538
)
15391539

1540-
if check_kind == "raster" and kind not in ("file", "grid", "arg"):
1541-
raise GMTInvalidInput(f"Unrecognized data type for grid: {type(data)}")
1542-
if check_kind == "vector" and kind not in (
1543-
"file",
1544-
"matrix",
1545-
"vectors",
1546-
"geojson",
1547-
"arg",
1548-
):
1549-
raise GMTInvalidInput(f"Unrecognized data type for vector: {type(data)}")
1540+
if check_kind == "raster":
1541+
valid_kinds = ("file", "grid")
1542+
elif check_kind == "vector":
1543+
valid_kinds = ("file", "matrix", "vectors", "geojson")
1544+
if required_data is False:
1545+
valid_kinds += "arg"
1546+
if kind not in valid_kinds:
1547+
raise GMTInvalidInput(
1548+
f"Unrecognized data type for {check_kind}: {type(data)}"
1549+
)
15501550

15511551
# Decide which virtualfile_from_ function to use
15521552
_virtualfile_from = {

0 commit comments

Comments
 (0)