Skip to content

Commit

Permalink
Make _validate_data_input public and move it to Session.virtualfile_in
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Jul 17, 2024
1 parent 318a8c4 commit 48e1378
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 10 additions & 0 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
data_kind,
tempfile_from_geojson,
tempfile_from_image,
validate_data_input,
)

FAMILIES = [
Expand Down Expand Up @@ -1594,6 +1595,15 @@ def virtualfile_in( # noqa: PLR0912
kind = data_kind(
data, x, y, z, required_z=required_z, required_data=required_data
)
validate_data_input(
data=data,
x=x,
y=y,
z=z,
required_z=required_z,
required_data=required_data,
kind=kind,
)

if check_kind:
valid_kinds = ("file", "arg") if required_data is False else ("file",)
Expand Down
1 change: 1 addition & 0 deletions pygmt/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
is_nonstr_iter,
launch_external_viewer,
non_ascii_to_octal,
validate_data_input,
)
from pygmt.helpers.validators import validate_output_table_type
11 changes: 1 addition & 10 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pygmt.exceptions import GMTInvalidInput


def _validate_data_input(
def validate_data_input(
data=None, x=None, y=None, z=None, required_z=False, required_data=True, kind=None
):
"""
Expand Down Expand Up @@ -193,15 +193,6 @@ def data_kind(data=None, x=None, y=None, z=None, required_z=False, required_data
kind = "matrix"
else:
kind = "vectors"
_validate_data_input(
data=data,
x=x,
y=y,
z=z,
required_z=required_z,
required_data=required_data,
kind=kind,
)
return kind


Expand Down

0 comments on commit 48e1378

Please sign in to comment.