Skip to content

pygmt.project: Fix the bug that passing x/y/z is not allowed - #4866

Open
seisman wants to merge 3 commits into
mainfrom
project/xyz
Open

pygmt.project: Fix the bug that passing x/y/z is not allowed#4866
seisman wants to merge 3 commits into
mainfrom
project/xyz

Conversation

@seisman

@seisman seisman commented Aug 27, 2026

Copy link
Copy Markdown
Member

project accepts both data or x/y/z inputs, but currently passing x/y/z raises an exception.

Here is the minimal example to reproduce the bug:

In [1]: import pygmt

In [2]: pygmt.project(
   ...:     data=[[0, 0], [1, 1]],
   ...:     center=[0, -1], azimuth=45, flat_earth=True,
   ...: )
Out[2]:
     0    1         2         3    4             5
0  0.0  1.0  1.414214  1.414214  1.0 -1.773023e-16
1  0.0  1.0  1.414214  1.414214  1.0 -1.773023e-16

In [3]: pygmt.project(x=[0, 1], y=[0, 1], center=[0, -1], azimuth=45, flat_earth=True)
---------------------------------------------------------------------------
GMTParameterError                         Traceback (most recent call last)
Cell In[3], line 1
----> 1 pygmt.project(x=[0, 1], y=[0, 1], center=[0, -1], azimuth=45, flat_earth=True)

File ~/OSS/gmt/pygmt/pygmt/helpers/decorators.py:599, in use_alias.<locals>.alias_decorator.<locals>.new_module(*args, **kwargs)
    592 if "Y" in kwargs or "yshift" in kwargs:
    593     raise GMTParameterError(
    594         reason=(
    595             "Parameters 'Y' and 'yshift' are no longer supported since 0.12.0. "
    596             "Use Figure.shift_origin(yshift=...) instead."
    597         )
    598     )
--> 599 return module_func(*args, **kwargs)

File ~/OSS/gmt/pygmt/pygmt/src/project.py:227, in project(data, x, y, z, output_type, outfile, azimuth, center, endpoint, width, length, pole, verbose, coltypes, **kwargs)
    225     raise GMTParameterError(required="center")
    226 if kwargs.get("G") is None and data is None:
--> 227     raise GMTParameterError(
    228         required="data", reason="Required unless 'generate' is set."
    229     )
    230 if kwargs.get("G") is not None and kwargs.get("F") is not None:
    231     raise GMTParameterError(at_most_one=["convention", "generate"])

GMTParameterError: Missing required parameter: 'data'. Required unless 'generate' is set.

This PR fixes the issue and adds a test.

@seisman seisman added this to the 0.20.0 milestone Aug 27, 2026
@seisman seisman added bug Something isn't working needs review This PR has higher priority and needs review. labels Aug 27, 2026
Comment thread pygmt/src/project.py
z=z,
mincols=2,
required=False,
required=aliasdict.get("G") is None,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

data or x/y/z is required if -G option (generate mode) is not set.

Comment thread pygmt/src/project.py Outdated
Comment thread pygmt/tests/test_project.py Outdated
Comment thread pygmt/tests/test_project.py Outdated
Comment thread pygmt/tests/test_project.py Outdated
Comment thread pygmt/tests/test_project.py Outdated
seisman and others added 2 commits August 27, 2026 19:15
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants