GeezerVison is showing github.com — Figure.basemap/Figure.coast: Deprecate the 'map_scale' parameter. Use… · GenericMappingTools/pygmt@4ab63e9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: pygmt/src/basemap.py +21-11Lines changed: 21 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | basemap - Plot base maps and frames. | 3 | 3 | """ | 4 | 4 |
| | 5 | +import warnings | 5 | 6 | from collections.abc import Sequence | 6 | 7 | from typing import Literal | 7 | 8 |
| | 11 | 12 |
| 12 | 13 |
| 13 | 14 | @fmt_docstring | 14 | | -@use_alias( | 15 | | - L="map_scale", | 16 | | - F="box", | 17 | | - Td="rose", | 18 | | - Tm="compass", | 19 | | - f="coltypes", | 20 | | -) | 21 | | -def basemap( | | 15 | +@use_alias(F="box", Td="rose", Tm="compass", f="coltypes") | | 16 | +def basemap( # noqa: PLR0913 | 22 | 17 | self, | 23 | 18 | projection: str | None = None, | 24 | 19 | zsize: float | str | None = None, | 25 | 20 | zscale: float | str | None = None, | 26 | 21 | frame: str | Sequence[str] | bool = False, | 27 | 22 | region: Sequence[float | str] | str | None = None, | | 23 | + map_scale: str | None = None, | 28 | 24 | verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"] | 29 | 25 | | bool = False, | 30 | 26 | panel: int | Sequence[int] | bool = False, | @@ -50,6 +46,7 @@ def basemap( | 50 | 46 | - J = projection | 51 | 47 | - Jz = zscale | 52 | 48 | - JZ = zsize | | 49 | + - L = map_scale | 53 | 50 | - R = region | 54 | 51 | - V = verbose | 55 | 52 | - c = panel | @@ -64,10 +61,13 @@ def basemap( | 64 | 61 | $region | 65 | 62 | *Required if this is the first plot command.* | 66 | 63 | $frame | 67 | | - map_scale : str | 68 | | - [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ | 69 | | - **+w**\ *length*. | | 64 | + map_scale | 70 | 65 | Draw a simple map scale centered on the reference point specified. | | 66 | +
| | 67 | + .. deprecated:: 0.18.0 | | 68 | +
| | 69 | + The ``map_scale`` parameter is deprecated and will be removed in a | | 70 | + future version. Use :meth:`pygmt.Figure.scalebar` instead. | 71 | 71 | box : bool or str | 72 | 72 | [**+c**\ *clearances*][**+g**\ *fill*][**+i**\ [[*gap*/]\ *pen*]]\ | 73 | 73 | [**+p**\ [*pen*]][**+r**\ [*radius*]][**+s**\ [[*dx*/*dy*/][*shade*]]]. | @@ -100,9 +100,19 @@ def basemap( | 100 | 100 | """ | 101 | 101 | self._activate_figure() | 102 | 102 |
| | 103 | + if kwargs.get("L", map_scale) is not None: | | 104 | + warnings.warn( | | 105 | + "The 'map_scale' parameter in 'Figure.basemap' is deprecated in v0.18.0 and " | | 106 | + "will be removed in a future version. " | | 107 | + "To add a scale bar, use 'Figure.scalebar' instead.", | | 108 | + FutureWarning, | | 109 | + stacklevel=3, | | 110 | + ) | | 111 | + | 103 | 112 | aliasdict = AliasSystem( | 104 | 113 | Jz=Alias(zscale, name="zscale"), | 105 | 114 | JZ=Alias(zsize, name="zsize"), | | 115 | + L=Alias(map_scale, name="map_scale"), | 106 | 116 | ).add_common( | 107 | 117 | B=frame, | 108 | 118 | J=projection, | |
Collapse file Copy file name to clipboardExpand all lines: pygmt/src/coast.py +19-3Lines changed: 19 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | coast - Plot continents, countries, shorelines, rivers, and borders. | 3 | 3 | """ | 4 | 4 |
| | 5 | +import warnings | 5 | 6 | from collections.abc import Sequence | 6 | 7 | from typing import Literal | 7 | 8 |
| | 15 | 16 |
| 16 | 17 |
| 17 | 18 | @fmt_docstring | 18 | | -@use_alias(A="area_thresh", C="lakes", E="dcw", L="map_scale") | | 19 | +@use_alias(A="area_thresh", C="lakes", E="dcw") | 19 | 20 | def coast( # noqa: PLR0913 | 20 | 21 | self, | 21 | 22 | resolution: Literal[ | @@ -26,6 +27,7 @@ def coast( # noqa: PLR0913 | 26 | 27 | rivers: int | str | Sequence[int | str] | None = None, | 27 | 28 | borders: int | str | Sequence[int | str] | None = None, | 28 | 29 | shorelines: bool | str | Sequence[int | str] = False, | | 30 | + map_scale: str | None = None, | 29 | 31 | box: Box | bool = False, | 30 | 32 | projection: str | None = None, | 31 | 33 | frame: str | Sequence[str] | bool = False, | @@ -131,9 +133,13 @@ def coast( # noqa: PLR0913 | 131 | 133 | - ``rivers=["1/0.5p,blue", "5/0.3p,cyan,dashed"]``: Draw permanent major rivers | 132 | 134 | with a 0.5-point blue pen and intermittent major rivers with a 0.3-point | 133 | 135 | dashed cyan pen. | 134 | | - map_scale : str | 135 | | - [**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\ **+w**\ *length*. | | 136 | + map_scale | 136 | 137 | Draw a simple map scale centered on the reference point specified. | | 138 | +
| | 139 | + .. deprecated:: 0.18.0 | | 140 | +
| | 141 | + The ``map_scale`` parameter is deprecated and will be removed in a | | 142 | + future version. Use :meth:`pygmt.Figure.scalebar` instead. | 137 | 143 | box | 138 | 144 | Draw a background box behind the map scale or rose. If set to ``True``, a simple | 139 | 145 | rectangular box is drawn using :gmt-term:`MAP_FRAME_PEN`. To customize the box | @@ -240,6 +246,15 @@ def coast( # noqa: PLR0913 | 240 | 246 | ) | 241 | 247 | raise GMTInvalidInput(msg) | 242 | 248 |
| | 249 | + if kwargs.get("L", map_scale) is not None: | | 250 | + warnings.warn( | | 251 | + "The 'map_scale' parameter in 'Figure.coast' is deprecated in v0.18.0 and " | | 252 | + "will be removed in a future version. " | | 253 | + "To add a scale bar, use 'Figure.scalebar' instead.", | | 254 | + FutureWarning, | | 255 | + stacklevel=3, | | 256 | + ) | | 257 | + | 243 | 258 | aliasdict = AliasSystem( | 244 | 259 | D=Alias( | 245 | 260 | resolution, | @@ -256,6 +271,7 @@ def coast( # noqa: PLR0913 | 256 | 271 | F=Alias(box, name="box"), | 257 | 272 | G=Alias(land, name="land"), | 258 | 273 | I=Alias(rivers, name="rivers"), | | 274 | + L=Alias(map_scale, name="map_scale"), | 259 | 275 | N=Alias(borders, name="borders"), | 260 | 276 | S=Alias(water, name="water"), | 261 | 277 | W=Alias(shorelines, name="shorelines"), | |
Collapse file Copy file name to clipboardExpand all lines: pygmt/tests/test_basemap.py +7-6Lines changed: 7 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -121,12 +121,13 @@ def test_basemap_map_scale(): | 121 | 121 | Create a map with a map scale. | 122 | 122 | """ | 123 | 123 | fig = Figure() | 124 | | - fig.basemap( | 125 | | - region=[127.5, 128.5, 26, 27], | 126 | | - projection="H15c", | 127 | | - frame=True, | 128 | | - map_scale="jMC+c26.5+w10k+f+l", | 129 | | - ) | | 124 | + with pytest.warns(FutureWarning): | | 125 | + fig.basemap( | | 126 | + region=[127.5, 128.5, 26, 27], | | 127 | + projection="H15c", | | 128 | + frame=True, | | 129 | + map_scale="jMC+c26.5+w10k+f+l", | | 130 | + ) | 130 | 131 | return fig | 131 | 132 |
| 132 | 133 |
| |
|