Skip to content

Conversation

@weiji14
Copy link
Member

@weiji14 weiji14 commented Sep 19, 2021

Description of proposed changes

This PR modifies the if-statement check in data_kind helper function to use len(data.data_vars) to check the shape of xarray.Dataset inputs. Added two regression tests in test_clib and test_blockm to ensure this works on both the low-level clib and high-level module APIs.

Originally posted by @weiji14 in #1478 (comment)

Checking for data.shape[1] fails for xarray.Dataset inputs with AttributeError: 'Dataset' object has no attribute 'shape'. The shapeattribute is valid only fornumpy.ndarray, pandas.DataFrame, and maybe a few other PyData objects. Will need to create a bugfix and add some extra tests for xarray.Dataset` inputs.

For a list of data formats supported by PyGMT, see #1268.

Patches #1478, addressing #1478 (comment).

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

Modify if-statement check in `data_kind` helper function
to use `len(data.data_vars)` to check the shape of
xarray.Dataset inputs. Added two regression tests in
test_clib and test_blockm to ensure this works on both the
low-level clib and high-level module APIs.
@weiji14 weiji14 self-assigned this Sep 19, 2021
@weiji14 weiji14 added the bug Something isn't working label Sep 19, 2021
@weiji14 weiji14 added this to the 0.5.0 milestone Sep 19, 2021
@weiji14 weiji14 added the skip-changelog Skip adding Pull Request to changelog label Sep 19, 2021
@weiji14 weiji14 mentioned this pull request Sep 19, 2021
5 tasks
@weiji14 weiji14 marked this pull request as ready for review September 19, 2021 11:32
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Sep 20, 2021
@weiji14 weiji14 merged commit bafb8ab into main Sep 20, 2021
@weiji14 weiji14 deleted the fix/xr-dataset-required-z branch September 20, 2021 22:34
@weiji14 weiji14 removed the final review call This PR requires final review and approval from a second reviewer label Sep 20, 2021
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…ls#1523)

Modify if-statement check in `data_kind` helper function
to use `len(data.data_vars)` to check the shape of
xarray.Dataset inputs. Added two regression tests in
test_clib and test_blockm to ensure this works on both the
low-level clib and high-level module APIs.

* Mention required_z parameter in docstring

Co-authored-by: Dongdong Tian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants