Add the validate_output_table_type function to check the output_type parameter#2772
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 <94163266+yvonnefroehlich@users.noreply.github.com>
|
Ping @GenericMappingTools/pygmt-maintainers for review. |
pygmt/src/grdhisteq.py
Outdated
| fmt_docstring, | ||
| kwargs_to_strings, | ||
| use_alias, | ||
| validate_output_type, |
There was a problem hiding this comment.
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.
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.
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.
Ah right, tables use outfile but grids use outgrid.
There was a problem hiding this comment.
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_typefunction so it can be re-used in many modules.Reminders
make formatandmake checkto 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