Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pygmt/src/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ def project( # noqa: PLR0913
if kwargs.get("G") is not None and kwargs.get("F") is not None:
raise GMTParameterError(at_most_one=["convention", "generate"])

# Input validation for only one geometry parameter
geometry_params = [
kwargs.get("A") is not None,
Comment thread
willschlitzer marked this conversation as resolved.
Outdated
kwargs.get("E", endpoint) is not None,
kwargs.get("T", pole) is not None,
]
if sum(geometry_params) > 1:
raise GMTParameterError(at_most_one=["azimuth", "endpoint", "pole"])

output_type = validate_output_table_type(output_type, outfile=outfile)

column_names = None
Expand Down
16 changes: 16 additions & 0 deletions pygmt/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ def test_project_incorrect_parameters():
with pytest.raises(GMTParameterError):
# Using `generate` with `convention`
project(center=[0, -1], generate=0.5, convention="xypqrsz")


def test_project_geometry_definition_validation(dataframe):
"""
Validate input validation for mutually
exclusive projection geometry parameters.
Comment thread
seisman marked this conversation as resolved.
Outdated
"""
with pytest.raises(GMTParameterError):
project(
center=[0, -1],
generate=0.5,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When generate is used, data should not be allowed, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I read the docs, the it just says that data will be ignored if generate is set. I removed this line from my PR. Should there be an input validation for data when generate is set?

data=dataframe,
endpoint=[0, 1],
azimuth=45,
pole=[0, 90],
)
Comment thread
willschlitzer marked this conversation as resolved.
Outdated
Loading