Skip to content

Commit

Permalink
Fix the logic of checking kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Aug 2, 2023
1 parent a6b85e2 commit 83a6360
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,16 +1537,18 @@ def virtualfile_from_data(
data, x, y, z, required_z=required_z, required_data=required_data
)

if check_kind == "raster" and kind not in ("file", "grid", "arg"):
raise GMTInvalidInput(f"Unrecognized data type for grid: {type(data)}")
if check_kind == "vector" and kind not in (
"file",
"matrix",
"vectors",
"geojson",
"arg",
):
raise GMTInvalidInput(f"Unrecognized data type for vector: {type(data)}")
if check_kind == "raster":
valid_kinds = ("file", "grid")
elif check_kind == "vector":
valid_kinds = ("file", "matrix", "vectors", "geojson")
else:
valid_kinds = ()
if required_data is False:
valid_kinds += ("arg",)
if kind not in valid_kinds:
raise GMTInvalidInput(
f"Unrecognized data type for {check_kind}: {type(data)}"
)

# Decide which virtualfile_from_ function to use
_virtualfile_from = {
Expand Down

0 comments on commit 83a6360

Please sign in to comment.