-
Notifications
You must be signed in to change notification settings - Fork 215
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
TYP: Improve the doc style for type hints #2813
Changes from 6 commits
cc6c461
5c5864c
9ceacb9
c7be7b1
66c4e69
7a3189a
15b2c07
f3c1b19
4bc5912
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
|
||
The grids are available in various resolutions. | ||
""" | ||
from collections.abc import Sequence | ||
from typing import Literal, Union | ||
|
||
from pygmt.datasets.load_remote_dataset import _load_remote_dataset | ||
from pygmt.exceptions import GMTInvalidInput | ||
from pygmt.helpers import kwargs_to_strings | ||
|
@@ -14,9 +17,9 @@ | |
@kwargs_to_strings(region="sequence") | ||
def load_earth_relief( | ||
resolution="01d", | ||
region=None, | ||
registration=None, | ||
data_source="igpp", | ||
region: Union[str, Sequence, None] = None, | ||
registration: Literal["gridline", "pixel", None] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree that the signature of No 1 is too complicated. The highlighting of No 3 and No 4 is good, as it is consistent with the rest of the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We don't have to give a default value, but I feel a default value in the function strings is good so that users don't have to go back to the function signature to know the default.
Yes, it's misleading. We can rephrase it to something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I also think it's good to have the default value in the function string. Just thought about not stating it for cases like above, but rephrasing the docstring should also prevent confusion. |
||
data_source: Literal["igpp", "gebco", "gebcosi", "synbath"] = "igpp", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's possible. |
||
use_srtm=False, | ||
): | ||
r""" | ||
|
@@ -63,18 +66,18 @@ def load_earth_relief( | |
``"04m"``, ``"03m"``, ``"02m"``, ``"01m"``, ``"30s"``, ``"15s"``, | ||
``"03s"``, or ``"01s"``. | ||
|
||
region : str or list | ||
region | ||
The subregion of the grid to load, in the form of a list | ||
[*xmin*, *xmax*, *ymin*, *ymax*] or a string *xmin/xmax/ymin/ymax*. | ||
Required for Earth relief grids with resolutions higher than 5 | ||
arc-minutes (i.e., ``"05m"``). | ||
|
||
registration : str | ||
registration | ||
Grid registration type. Either ``"pixel"`` for pixel registration or | ||
``"gridline"`` for gridline registration. Default is ``"gridline"`` | ||
for all resolutions except ``"15s"`` which is ``"pixel"`` only. | ||
|
||
data_source : str | ||
data_source | ||
Select the source for the Earth relief data. Available options are: | ||
|
||
- ``"igpp"``: IGPP Earth Relief [Default option]. See | ||
|
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.
Need to revert any changes in this file before merging.