Skip to content

Commit 1dda5d2

Browse files
authored
Merge branch 'main' into feature/magnetic_rose
2 parents be5f819 + 37a2e44 commit 1dda5d2

File tree

8 files changed

+58
-34
lines changed

8 files changed

+58
-34
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484

8585
# Run the benchmark tests
8686
- name: Run benchmarks
87-
uses: CodSpeedHQ/action@6a8e2b874c338bf81cc5e8be715ada75908d3871 # v4.3.4
87+
uses: CodSpeedHQ/action@346a2d8a8d9d38909abd0bc3d23f773110f076ad # v4.4.1
8888
with:
8989
mode: "instrumentation"
9090
# 'bash -el -c' is needed to use the custom shell.

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
GH_TOKEN: ${{ github.token }}
152152

153153
- name: Install uv
154-
uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4
154+
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
155155
with:
156156
activate-environment: true
157157
python-version: ${{ matrix.python-version }}

doc/contributing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ integration systems will warn us and you can make a new commit with the formatte
488488
Even better, you can just write `/format` in the first line of any comment in a
489489
pull request to lint the code automatically.
490490

491-
When wrapping a new alias, use an underscore to separate words bridged by vowels
492-
(aeiou), such as `no_skip` and `z_only`. Do not use an underscore to separate
493-
words bridged only by consonants, such as `distcalc`, and `crossprofile`. This
494-
convention is not applied by the code checking tools, but the PyGMT maintainers
491+
When introducing a new parameter name, use an underscore to separate words. This improves
492+
readability and aligns with the [PEP 8 style guide](https://peps.python.org/pep-0008/).
493+
For common shortcuts no underscore is needed, e.g., `surftype`, `outgrid`, or `timefmt`.
494+
This convention is not applied by the code checking tools, but the PyGMT maintainers
495495
will comment on any pull requests as needed.
496496

497497
When working on a tutorial or a gallery plot, it is good practice to use code

examples/tutorials/advanced/cartesian_histograms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
# Grouped bars
321321
# ------------
322322
#
323-
# By setting the ``barwidth`` parameter in respect to the values passed to the
323+
# By setting the ``bar_width`` parameter in respect to the values passed to the
324324
# ``series`` parameter histograms with grouped bars can be created.
325325
#
326326
# Limitations of histograms with grouped bars are:
@@ -347,7 +347,7 @@
347347
# of the bin width
348348
# Offset ("+o") the bars to align each bar with the left limit of the corresponding
349349
# bin
350-
barwidth=f"{binwidth / 2}+o-{binwidth / 4}",
350+
bar_width=f"{binwidth / 2}+o-{binwidth / 4}",
351351
label="data01",
352352
)
353353

@@ -358,7 +358,7 @@
358358
fill="orange",
359359
pen="1p,darkgray,solid",
360360
histtype=0,
361-
barwidth=f"{binwidth / 2}+o{binwidth / 4}",
361+
bar_width=f"{binwidth / 2}+o{binwidth / 4}",
362362
label="data02",
363363
)
364364

pygmt/src/grdview.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
from typing import Literal
77

88
import xarray as xr
9+
from packaging.version import Version
910
from pygmt._typing import PathLike
1011
from pygmt.alias import Alias, AliasSystem
11-
from pygmt.clib import Session
12+
from pygmt.clib import Session, __gmt_version__
1213
from pygmt.helpers import build_arg_list, deprecate_parameter, fmt_docstring, use_alias
14+
from pygmt.src.grdinfo import grdinfo
1315

1416
__doctest_skip__ = ["grdview"]
1517

@@ -116,6 +118,8 @@ def grdview( # noqa: PLR0913
116118
value in the grid. However, if ``region`` was used to set *zmin/zmax* then
117119
*zmin* is used if it is less than the grid minimum value. Use ``facade_pen`` and
118120
``facade_fill`` to control the appearance of the plane.
121+
**Note**: For GMT<=6.6.0, *zmin* set in ``region`` has no effect due to a GMT
122+
bug.
119123
facade_fill
120124
Fill for the frontal facade between the plane specified by ``plane`` and the
121125
data perimeter.
@@ -174,6 +178,18 @@ def grdview( # noqa: PLR0913
174178
if plane is False and (facade_fill is not None or facade_pen is not None):
175179
plane = True
176180

181+
# Workaround for GMT bug https://github.com/GenericMappingTools/gmt/pull/8838
182+
# Fix the plane value to be the grid minimum if plane=True.
183+
# Notes:
184+
# 1. It's the minimum of the grid, not a subset of the grid defined by 'region'.
185+
# 2. The GMT docs says "if -R was used to set zmin/zmax then we use that value if
186+
# it is less than the grid minimum value.". We can't add a workaround for this
187+
# case since we can't parse zmin/zmax from 'region' if 'region' was set in
188+
# previous plotting commands.
189+
# TODO(GMT>6.6.0): Remove this workaround.
190+
if Version(__gmt_version__) <= Version("6.6.0") and plane is True:
191+
plane = grdinfo(grid, per_column=True).split()[4]
192+
177193
aliasdict = AliasSystem(
178194
Jz=Alias(zscale, name="zscale"),
179195
JZ=Alias(zsize, name="zsize"),

pygmt/src/histogram.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88
from pygmt._typing import PathLike, TableLike
99
from pygmt.alias import AliasSystem
1010
from pygmt.clib import Session
11-
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
11+
from pygmt.helpers import (
12+
build_arg_list,
13+
deprecate_parameter,
14+
fmt_docstring,
15+
kwargs_to_strings,
16+
use_alias,
17+
)
1218

1319

1420
@fmt_docstring
21+
@deprecate_parameter("barwidth", "bar_width", "v0.18.0", remove_version="v0.20.0")
1522
@use_alias(
1623
A="horizontal",
1724
C="cmap",
1825
D="annotate",
19-
E="barwidth",
26+
E="bar_width",
2027
F="center",
2128
G="fill",
2229
L="extreme",
@@ -84,7 +91,7 @@ def histogram(
8491
annotation font; use **+o** to change the offset between bar and
8592
label [Default is ``"6p"``]; use **+r** to rotate the labels from
8693
horizontal to vertical.
87-
barwidth : float or str
94+
bar_width : float or str
8895
*width*\ [**+o**\ *offset*].
8996
Use an alternative histogram bar width than the default set via
9097
``series``, and optionally shift all bars by an *offset*. Here

pygmt/src/select.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pygmt.clib import Session
1313
from pygmt.helpers import (
1414
build_arg_list,
15+
deprecate_parameter,
1516
fmt_docstring,
1617
kwargs_to_strings,
1718
use_alias,
@@ -22,14 +23,16 @@
2223

2324

2425
@fmt_docstring
26+
@deprecate_parameter("mask", "mask_values", "v0.18.0", remove_version="v0.20.0")
27+
@deprecate_parameter("gridmask", "mask_grid", "v0.18.0", remove_version="v0.20.0")
2528
@use_alias(
2629
A="area_thresh",
2730
C="dist2pt",
2831
F="polygon",
29-
G="gridmask",
32+
G="mask_grid",
3033
I="reverse",
3134
L="dist2line",
32-
N="mask",
35+
N="mask_values",
3336
Z="z_subregion",
3437
b="binary",
3538
d="nodata",
@@ -128,42 +131,40 @@ def select(
128131
<reference/file-formats.html#optional-segment-header-records>`
129132
*polygonfile*. For spherical polygons (lon, lat), make sure no
130133
consecutive points are separated by 180 degrees or more in longitude.
131-
gridmask : str
134+
mask_grid : str
132135
Pass all locations that are inside the valid data area of the grid
133-
*gridmask*. Nodes that are outside are either NaN or zero.
136+
*mask_grid*. Nodes that are outside are either NaN or zero.
134137
reverse : str
135138
[**cflrsz**].
136139
Reverse the sense of the test for each of the criteria specified:
137140
138141
- **c** select records NOT inside any point's circle of influence.
139142
- **f** select records NOT inside any of the polygons.
140143
- **g** will pass records inside the cells with z equal zero of the
141-
grid mask in ``gridmask``.
144+
*mask_grid* in ``mask_grid``.
142145
- **l** select records NOT within the specified distance of any line.
143146
- **r** select records NOT inside the specified rectangular region.
144-
- **s** select records NOT considered inside as specified by ``mask``
147+
- **s** select records NOT considered inside as specified by ``mask_values``
145148
(and ``area_thresh``, ``resolution``).
146149
- **z** select records NOT within the range specified by
147150
``z_subregion``.
148151
$projection
149-
mask : str or list
150-
Pass all records whose location is inside specified geographical
151-
features. Specify if records should be skipped (s) or kept (k) using
152-
1 of 2 formats:
152+
mask_values : str or list
153+
Pass all records whose location is inside specified geographical features.
154+
Specify if records should be skipped (s) or kept (k) using 1 of 2 formats:
153155
154156
- *wet/dry*.
155157
- *ocean/land/lake/island/pond*.
156158
157-
[Default is s/k/s/k/s (i.e., s/k), which passes all points on dry
158-
land].
159+
[Default is s/k/s/k/s (i.e., s/k), which passes all points on dry land].
159160
resolution
160-
Ignored unless ``mask`` is set. Select the resolution of the coastline dataset
161-
to use. The available resolutions from highest to lowest are: ``"full"``,
162-
``"high"``, ``"intermediate"``, ``"low"``, and ``"crude"``, which drops by 80%
163-
between levels. Alternatively, choose ``"auto"`` to automatically select the
164-
most suitable resolution given the chosen region. Note that because the
165-
coastlines differ in details, a node in a mask file using one resolution is not
166-
guaranteed to remain inside [or outside] when a different resolution is
161+
Ignored unless ``mask_values`` is set. Select the resolution of the coastline
162+
dataset to use. The available resolutions from highest to lowest are:
163+
``"full"``, ``"high"``, ``"intermediate"``, ``"low"``, and ``"crude"``, which
164+
drops by 80% between levels. Alternatively, choose ``"auto"`` to automatically
165+
select the most suitable resolution given the chosen region. Note that because
166+
the coastlines differ in details, a node in a mask file using one resolution is
167+
not guaranteed to remain inside [or outside] when a different resolution is
167168
selected. If ``None``, the low resolution is used by default.
168169
$region
169170
$verbose
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
outs:
2-
- md5: cfff4879fbe7ab03d8a304b2622b9782
3-
size: 26208
2+
- md5: aa725f7d05462e7d272cf7045a7c9913
3+
size: 32037
44
hash: md5
55
path: test_grdview_facadepen_default_plane.png

0 commit comments

Comments
 (0)