-
Notifications
You must be signed in to change notification settings - Fork 224
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
Handling data processing functions that output to a grid or table #1536
Comments
I like the syntax of the class method style, but dislike using classes in a functional programming style with the In https://github.com/GenericMappingTools/pygmt/tree/grdhisteq-functions, I tried to implement a syntax similar to the class based option and the |
The implementation of grdhisteq in #1433 uses the "Two methods in a single Python class" style and is currently on a final review call. If that PR gets merged, I think we should stick with that style for the other functions that output to a grid or table for consistency. So, please comment either here or in that PR if anyone does not like that design choice. |
Thanks Meghan for getting the |
Just a note that this issue can be closed after the recommended structure (as used in grdhisteq and triangulate) is added to the contributing guide. The guidance could be added as a follow-up to #1687. |
The contributing guide is already too long, do you think we should add a code style guide instead? Here is an example from ObsPy https://docs.obspy.org/coding_style.html. |
Yes, a code style guide would be a good alternative. We could also move a bunch of the other information into a docs style guide if it's important to have the base contributing guide shorter. |
Description of the issue
In the GMT command-line world, there are some data processing functions that can output to either a NetCDF grid or ASCII table. Translating to Python/PyGMT, do we want to 1) have a single function that can output to both (depending on some flag), or 2) have two functions/methods, one which outputs to a grid, and one which outputs to a table.
This is a list of functions that need to be handled:
triangulate
Wrap triangulate #731grdhisteq
Wrap grdhisteq #1433binstats
Wrap binstats #1652 pygmt.binstats: Add alias "tiling" for "T" #2409Originally posted by @weiji14 in #1433 (comment)
Possible implementation styles
These are how the implementation would look like, using
triangulate
as an example.Single function
Two Python functions
Have a common
_triangulate
function that handles grid or table outputs, some similarities to the_blockm
.Two methods in a single Python class ✔️
Are you willing to help implement and maintain this feature? Vote for which API style you prefer!
pygmt.triangulate(outgrid=True)
orpygmt.triangulate(outfile=True)
pygmt.triangulate_to_grid()
orpygmt.triangulate_to_table()
pygmt.triangulate.to_grid()
orpygmt.triangulate.to_table()
P.S. Also xref #896 where there is a similar API design discussion on wrapping GMT functions that do either plotting or data processing.
The text was updated successfully, but these errors were encountered: