Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor blockm* to use virtualfile_from_data and improve i/o #1280

Merged
merged 10 commits into from
May 24, 2021

Conversation

maxrjones
Copy link
Member

Description of proposed changes

This PR makes the changes corresponding to #1189 for blockmean and blockmedian.

Enables blockm* to work with table-like inputs besides pandas.DataFrame. Also, the outfile parameter has become optional, and the output data will be loaded as a pandas.DataFrame when outfile is unset. Unit tests have been updated accordingly too.

Related to #949. Addresses #1099

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

@seisman seisman added this to the 0.4.0 milestone May 21, 2021
@seisman seisman added the enhancement Improving an existing feature label May 21, 2021
@weiji14
Copy link
Member

weiji14 commented May 21, 2021

The docstring for blockmean and blockmedian also needs to be updated to mention that other table-like inputs are accepted besides pandas.DataFrame.

@maxrjones
Copy link
Member Author

The docstring for blockmean and blockmedian also needs to be updated to mention that other table-like inputs are accepted besides pandas.DataFrame.

Since geopandas is now supported and included in {table-like} filler text, do I also need to add tests for geopandas input?

@seisman
Copy link
Member

seisman commented May 23, 2021

Since geopandas is now supported and included in {table-like} filler text, do I also need to add tests for geopandas input?

I think it's unnecessary. The geopandas support is independent with any specific modules and we already have it tested in the test_geopandas.py file.

Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label May 23, 2021
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Thanks Meghan for the work, I think we can close #1099 with this PR too no?

Since geopandas is now supported and included in {table-like} filler text, do I also need to add tests for geopandas input?

I think it's unnecessary. The geopandas support is independent with any specific modules and we already have it tested in the test_geopandas.py file.

Agree that we don't need a geopandas input test here.

However, this got me to think about how the PyGMT I/O should work if a geopandas.GeoDataFrame is used as an input to blockm*. Should we yield a pandas.DataFrame output, or would users prefer a geopandas.GeoDataFrame to be returned here? Something to think about in a separate issue.

@weiji14 weiji14 mentioned this pull request May 24, 2021
5 tasks
@maxrjones maxrjones linked an issue May 24, 2021 that may be closed by this pull request
2 tasks
@maxrjones
Copy link
Member Author

I think we can close #1099 with this PR too no?

Yes, it is now linked.

However, this got me to think about how the PyGMT I/O should work if a geopandas.GeoDataFrame is used as an input to blockm*. Should we yield a pandas.DataFrame output, or would users prefer a geopandas.GeoDataFrame to be returned here? Something to think about in a separate issue.

Some users would probably like the option. This could be a good SciPy sprint issue.

@seisman
Copy link
Member

seisman commented May 24, 2021

I think we can close #1099 with this PR too no?

What's still missing is x/y/z type input like other functions.

@weiji14
Copy link
Member

weiji14 commented May 24, 2021

I think we can close #1099 with this PR too no?

What's still missing is x/y/z type input like other functions.

Ah ok, I've unlinked #1099 from being closed. We'll handle the x/y/z inputs for blockmean, blockmedian and grdtrack in a separate PR. Feel free to merge this one in Meghan since tests have all passed now.

@maxrjones maxrjones merged commit 891c5ed into master May 24, 2021
@maxrjones maxrjones deleted the refactor-blockm branch May 24, 2021 13:02
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label May 27, 2021
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…cMappingTools#1280)

- Enables blockm* to work with table-like inputs besides pandas.DataFrame
- Makes outfile parameter optional
- Loads output data as a pandas.DataFrame when outfile is unset
- Updates unit tests accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants