-
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
Add the validate_output_table_type function to check the output_type parameter #2772
Conversation
e9500eb
to
c5b90fa
Compare
7fb9c42
to
cd11f98
Compare
Co-authored-by: Yvonne Fröhlich <[email protected]>
Ping @GenericMappingTools/pygmt-maintainers for review. |
pygmt/src/grdhisteq.py
Outdated
@@ -13,6 +12,7 @@ | |||
fmt_docstring, | |||
kwargs_to_strings, | |||
use_alias, | |||
validate_output_type, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just on the naming, should we specify that this applies to tabular outputs? E.g. use something like validate_output_table_type
? There are some functions like pygmt.grdhisteq.equalize_grid
that has code looking like this:
with GMTTempFile(suffix=".nc") as tmpfile:
if isinstance(outgrid, str):
output_type = "file"
elif outgrid is None:
output_type = "xarray"
outgrid = tmpfile.name
else:
raise GMTInvalidInput("Must specify 'outgrid' as a string or None.")
If we ever decide to have more output_types for grids (e.g. NetCDF or TIFF or xarray or ???), then there might be a validate_output_grid_type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about adding a new parameter kind
(valid values are dataset
/grid
) to make the function working for both tables and grids.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There would a lot of if-thens, and the error/warning messages would be different between tables and grids though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, tables use outfile
but grids use outgrid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just on the naming, should we specify that this applies to tabular outputs? E.g. use something like
validate_output_table_type
?
Renamed in becbb73.
Description of proposed changes
Add the
validate_output_type
function so it can be re-used in many modules.Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version