Skip to content

Commit 486c37a

Browse files
committed
Merge branch 'main' into python-3.12
2 parents 90a3a49 + 19639fe commit 486c37a

31 files changed

+635
-534
lines changed

.github/release-drafter.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ exclude-contributors:
2727
category-template: '### $TITLE'
2828
change-template: '* $TITLE ([#$NUMBER]($URL))'
2929
sort-by: 'title'
30+
replacers:
31+
- search: '/@(\w+)?/g'
32+
replace: '[@$1](https://github.com/$1)'
33+
- search: '@maxrjones'
34+
replace: 'Max Jones'
35+
- search: '@michaelgrund'
36+
replace: 'Michael Grund'
37+
- search: '@seisman'
38+
replace: 'Dongdong Tian'
39+
- search: '@weiji14'
40+
replace: 'Wei Ji Leong'
41+
- search: '@willschlitzer'
42+
replace: 'Will Schlitzer'
43+
- search: '@yvonnefroehlich'
44+
replace: 'Yvonne Fröhlich'
3045
template: |
3146
## Release v$RESOLVED_VERSION (20YY/MM/DD)
3247

.github/workflows/ci_docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
create-args: >-
7878
python=3.12
7979
gmt=6.4.0
80+
ghostscript=9.54.0
8081
numpy
8182
pandas
8283
xarray

.github/workflows/ci_tests_dev.yaml

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
# This workflow runs regular PyGMT tests with the GMT dev version, and also
44
# pre-release versions of several dependencies like NumPy, Pandas, Xarray, etc.
55
# If any tests fail, it also uploads the diff images as workflow artifacts.
6-
# On Linux/macOS, GMT dev version is installed by fetching the latest source
7-
# codes from the GMT master branch and compiling.
8-
# On Windows, GMT dev version is installed from the conda-forge's dev channel
9-
# due to the complexity of building GMT source codes on Windows.
6+
# The GMT dev version is installed by fetching the latest source codes from
7+
# the GMT master branch and compiling.
108
#
119
# It is triggered when a pull request is marked as "ready as review", or using
1210
# the slash command `/test-gmt-dev`. It is also scheduled to run on Monday,
@@ -80,7 +78,7 @@ jobs:
8078
fetch-depth: 0
8179

8280
- name: Show job URL
83-
uses: peter-evans/create-or-update-comment@v3.0.2
81+
uses: peter-evans/create-or-update-comment@v3.1.0
8482
if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest')
8583
with:
8684
token: ${{ steps.generate-token.outputs.token }}
@@ -116,6 +114,38 @@ jobs:
116114
pcre
117115
zlib
118116
117+
# Build and install latest GMT from GitHub
118+
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)
119+
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
120+
env:
121+
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
122+
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
123+
if: runner.os != 'Windows'
124+
125+
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Windows)
126+
shell: cmd
127+
run: |
128+
git clone --depth=1 --single-branch --branch ${{ env.GMT_GIT_REF }} https://github.com/GenericMappingTools/gmt
129+
cd gmt/
130+
mkdir build
131+
cd build
132+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
133+
cmake -G Ninja .. ^
134+
-DCMAKE_INSTALL_PREFIX=${{ env.GMT_INSTALL_DIR }} ^
135+
-DCMAKE_BUILD_TYPE=Release ^
136+
-DCMAKE_PREFIX_PATH=${{ env.MAMBA_ROOT_PREFIX }}\envs\pygmt\Library ^
137+
-DGMT_ENABLE_OPENMP=TRUE ^
138+
-DGMT_USE_THREADS=TRUE
139+
cmake --build .
140+
cmake --build . --target install
141+
env:
142+
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
143+
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
144+
if: runner.os == 'Windows'
145+
146+
- name: Add GMT's bin to PATH
147+
run: echo '${{ github.workspace }}/gmt-install-dir/bin' >> $GITHUB_PATH
148+
119149
# Install dependencies from PyPI
120150
- name: Install dependencies
121151
run: |
@@ -136,18 +166,6 @@ jobs:
136166
dvc pull
137167
ls -lhR pygmt/tests/baseline/
138168
139-
# Build and install latest GMT from GitHub
140-
- name: Install GMT ${{ matrix.gmt_git_ref }} branch (Linux/macOS)
141-
run: curl https://raw.githubusercontent.com/GenericMappingTools/gmt/master/ci/build-gmt.sh | bash
142-
env:
143-
GMT_GIT_REF: ${{ matrix.gmt_git_ref }}
144-
GMT_INSTALL_DIR: ${{ github.workspace }}/gmt-install-dir
145-
if: runner.os != 'Windows'
146-
147-
- name: Install GMT dev version from conda-forge (Windows)
148-
run: micromamba install -c conda-forge/label/dev gmt
149-
if: runner.os == 'Windows'
150-
151169
# Download cached remote files (artifacts) from GitHub
152170
- name: Download remote data from GitHub
153171
uses: dawidd6/[email protected]
@@ -170,21 +188,11 @@ jobs:
170188
- name: Install the package
171189
run: make install
172190

173-
- name: Add GMT's bin to PATH (Linux/macOS)
174-
run: echo ${GITHUB_WORKSPACE}/gmt-install-dir/bin >> $GITHUB_PATH
175-
if: runner.os != 'Windows'
176-
177191
# Run the tests
178-
- name: Test with pytest (Linux/macOS)
192+
- name: Test with pytest
179193
run: make test PYTEST_EXTRA="-r P"
180194
env:
181195
GMT_LIBRARY_PATH: ${{ github.workspace }}/gmt-install-dir/lib
182-
if: runner.os != 'Windows'
183-
184-
# Run the tests
185-
- name: Test with pytest (Windows)
186-
run: make test PYTEST_EXTRA="-r P"
187-
if: runner.os == 'Windows'
188196

189197
# Upload diff images on test failure
190198
- name: Upload diff images if any test fails

.github/workflows/dvc-diff.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ jobs:
3232
- name: Setup continuous machine learning (CML)
3333
uses: iterative/[email protected]
3434

35-
# workaround from https://github.com/iterative/cml/issues/1377
36-
- name: Setup NodeJS
37-
uses: actions/[email protected]
38-
with:
39-
node-version: '16'
40-
4135
# Produce the markdown diff report, which should look like:
4236
# ## Summary of changed images
4337
#
@@ -76,7 +70,7 @@ jobs:
7670
cp pygmt/tests/baseline/*.png pygmt/tests/baseline-new/
7771
# Pull images in the main branch from cloud storage
7872
git checkout main
79-
dvc pull --remote upstream
73+
dvc pull --remote upstream --force
8074
8175
# Append each image to the markdown report
8276
echo -e "## Image diff(s)\n" >> report.md

.github/workflows/format-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
fi
5151
5252
- name: Add reaction
53-
uses: peter-evans/create-or-update-comment@v3.0.2
53+
uses: peter-evans/create-or-update-comment@v3.1.0
5454
with:
5555
token: ${{ steps.generate-token.outputs.token }}
5656
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}

.github/workflows/release-baseline-images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
shasum -a 256 baseline-images.zip
3838
3939
- name: Upload baseline image as a release asset
40-
uses: shogo82148/[email protected].0
40+
uses: shogo82148/[email protected].2
4141
with:
4242
upload_url: ${{ github.event.release.upload_url }}
4343
asset_path: baseline-images.zip

ci/requirements/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ channels:
55
dependencies:
66
# Required dependencies
77
- gmt=6.4.0
8+
- ghostscript=9.54.0
89
- numpy>=1.22
910
- pandas
1011
- xarray

examples/gallery/embellishments/legend.py

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,60 @@
33
======
44
55
The :meth:`pygmt.Figure.legend` method can automatically create a legend for
6-
symbols plotted using :meth:`pygmt.Figure.plot`. Legend entries are only
7-
created when the ``label`` parameter is used. For more complicated legends,
8-
including legends with multiple columns, users have to write an ASCII file
9-
with instructions for the layout of the legend items and pass it
10-
to the ``spec`` parameter of :meth:`pygmt.Figure.legend`. For details on
11-
how to set up such a file, please see the GMT documentation at
12-
:gmt-docs:`legend.html#legend-codes`.
6+
symbols plotted using :meth:`pygmt.Figure.plot`. A legend entry is only added
7+
when the ``label`` parameter is used to state the desired text. Optionally,
8+
to adjust the legend, users can append different modifiers. A list of all
9+
available modifiers can be found at :gmt-docs:`gmt.html#l-full`. To create a
10+
multiple-column legend **+N** is used with the desired number of columns.
11+
For more complicated legends, users may want to write an ASCII file with
12+
instructions for the layout of the legend items and pass it to the ``spec``
13+
parameter of :meth:`pygmt.Figure.legend`. For details on how to set up such a
14+
file, please see the GMT documentation at :gmt-docs:`legend.html#legend-codes`.
1315
"""
1416

1517
# %%
18+
import numpy as np
1619
import pygmt
1720

18-
fig = pygmt.Figure()
21+
# Set up some test data
22+
x = np.arange(-10, 10.2, 0.2)
23+
y1 = np.sin(x) + 1.1
24+
y2 = np.cos(x) + 1.1
25+
y3 = np.sin(x / 2) - 1.1
26+
y4 = np.cos(x / 2) - 1.1
1927

20-
fig.basemap(projection="x2c", region=[0, 7, 3, 7], frame=True)
28+
# Create new Figure() object
29+
fig = pygmt.Figure()
2130

22-
fig.plot(
23-
data="@Table_5_11.txt",
24-
style="c0.40c",
25-
fill="lightgreen",
26-
pen="faint",
27-
label="Apples",
31+
fig.basemap(
32+
projection="X10c/7c",
33+
region=[-10, 10, -3.5, 3.5],
34+
frame=["WSne", "xaf+lx", "ya1f0.5+ly"],
2835
)
29-
fig.plot(data="@Table_5_11.txt", pen="1.5p,gray", label="My lines")
30-
fig.plot(data="@Table_5_11.txt", style="t0.40c", fill="orange", label="Oranges")
3136

37+
# -----------------------------------------------------------------------------
38+
# Top: Vertical legend (one column, default)
39+
40+
# Use the label parameter to state the text label for the legend entry
41+
fig.plot(x=x, y=y1, pen="1p,green3", label="sin(x)+1.1")
42+
43+
fig.plot(x=x, y=y2, style="c0.07c", fill="dodgerblue", label="cos(x)+1.1")
44+
45+
# Add a legend to the plot; place it within the plot bounding box with both
46+
# reference ("J") and anchor ("+j") points being TopRight and with an offset
47+
# of 0.2 centimeters in x and y directions; surround the legend with a box
3248
fig.legend(position="JTR+jTR+o0.2c", box=True)
3349

50+
# -----------------------------------------------------------------------------
51+
# Bottom: Horizontal legend (here two columns)
52+
53+
# +N sets the number of columns corresponding to the given number, here 2
54+
fig.plot(x=x, y=y3, pen="1p,darkred,-", label="sin(x/2)-1.1+N2")
55+
56+
fig.plot(x=x, y=y4, style="s0.07c", fill="orange", label="cos(x/2)-1.1")
57+
58+
# For a multi-column legend, users have to provide the width via "+w", here it
59+
# is set to 6 centimeters; reference and anchor points are set to BottomRight
60+
fig.legend(position="JBR+jBR+o0.2c+w6c", box=True)
61+
3462
fig.show()

examples/gallery/histograms/histogram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import numpy as np
1313
import pygmt
1414

15-
np.random.seed(100)
16-
1715
# Generate random elevation data from a normal distribution
16+
rng = np.random.default_rng(seed=100)
1817
mean = 100 # mean of distribution
1918
stddev = 25 # standard deviation of distribution
20-
data = mean + stddev * np.random.randn(521)
19+
data = rng.normal(loc=mean, scale=stddev, size=521)
20+
2121

2222
fig = pygmt.Figure()
2323

examples/gallery/histograms/scatter_and_histograms.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
import numpy as np
1414
import pygmt
1515

16-
np.random.seed(19680801)
17-
1816
# Generate random data from a standard normal distribution centered on 0
19-
x = np.random.randn(1000)
20-
y = np.random.randn(1000)
17+
# with a standard deviation of 1
18+
rng = np.random.default_rng(seed=19680801)
19+
x = rng.normal(loc=0, scale=1, size=1000)
20+
y = rng.normal(loc=0, scale=1, size=1000)
2121

2222
# Get axis limits
2323
xymax = max(np.max(np.abs(x)), np.max(np.abs(y)))
2424

25+
2526
fig = pygmt.Figure()
2627
fig.basemap(
2728
region=[-xymax - 0.5, xymax + 0.5, -xymax - 0.5, xymax + 0.5],

examples/gallery/lines/roads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
as lines which are stored in a :class:`geopandas.GeoDataFrame` object. Use
77
:func:`geopandas.read_file` to load data from any supported OGR format such as
88
a shapefile (.shp), GeoJSON (.geojson), geopackage (.gpkg), etc. Then, pass the
9-
:class:`geopandas.GeoDataFrame` as an argument to the ``data`` parameter in
9+
:class:`geopandas.GeoDataFrame` as an argument to the ``data`` parameter of
1010
:meth:`pygmt.Figure.plot`, and style the geometry using the ``pen`` parameter.
1111
"""
1212

examples/gallery/symbols/points.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
import pygmt
1212

1313
# Generate a random set of points to plot
14-
np.random.seed(42)
14+
rng = np.random.default_rng(seed=42)
1515
region = [150, 240, -10, 60]
16-
x = np.random.uniform(region[0], region[1], 100)
17-
y = np.random.uniform(region[2], region[3], 100)
16+
x = rng.uniform(low=region[0], high=region[1], size=100)
17+
y = rng.uniform(low=region[2], high=region[3], size=100)
18+
1819

1920
fig = pygmt.Figure()
2021
# Create a 15 cm x 15 cm basemap with a Cartesian projection (X) using the

examples/gallery/symbols/scatter.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
import numpy as np
1414
import pygmt
1515

16-
np.random.seed(19680801)
16+
rng = np.random.default_rng(seed=19680801)
1717
n = 200 # number of random data points
1818

1919
fig = pygmt.Figure()
2020
fig.basemap(
21-
region=[-0.1, 1.1, -0.1, 1.1],
21+
region=[-1, 1, -1, 1],
2222
projection="X10c/10c",
23-
frame=["xa0.2fg", "ya0.2fg", "WSrt"],
23+
frame=["xa0.5fg", "ya0.5fg", "WSrt"],
2424
)
2525
for fill in ["gray73", "darkorange", "slateblue"]:
26-
x, y = np.random.rand(2, n) # random X and Y data in [0,1]
27-
size = np.random.rand(n) * 0.5 # random size [0,0.5], in cm
26+
# Generate standard normal distributions centered on 0
27+
# with standard deviations of 1
28+
x = rng.normal(loc=0, scale=0.5, size=n) # random x data
29+
y = rng.normal(loc=0, scale=0.5, size=n) # random y data
30+
size = rng.normal(loc=0, scale=0.5, size=n) * 0.5 # random size, in cm
31+
2832
# plot data points as circles (style="c"), with different sizes
2933
fig.plot(
3034
x=x,

examples/tutorials/advanced/cartesian_histograms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
# %%
2323
# Generate random data from a normal distribution:
2424

25-
np.random.seed(100)
25+
rng = np.random.default_rng(seed=100)
2626

2727
# Mean of distribution
2828
mean = 100
2929
# Standard deviation of distribution
3030
stddev = 20
3131

3232
# Create two data sets
33-
data01 = np.random.normal(mean, stddev, 42)
34-
data02 = np.random.normal(mean, stddev * 2, 42)
33+
data01 = rng.normal(loc=mean, scale=stddev, size=42)
34+
data02 = rng.normal(loc=mean, scale=stddev * 2, size=42)
3535

3636

3737
# %%

pygmt/__init__.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def show_versions(file=sys.stdout):
109109
import platform
110110
import subprocess
111111

112+
from packaging.requirements import Requirement
113+
112114
def _get_module_version(modname):
113115
"""
114116
Get version information of a Python module.
@@ -153,17 +155,7 @@ def _get_ghostscript_version():
153155
"machine": platform.platform(),
154156
}
155157

156-
deps = [
157-
"numpy",
158-
"pandas",
159-
"xarray",
160-
"netCDF4",
161-
"packaging",
162-
"contextily",
163-
"geopandas",
164-
"IPython",
165-
"rioxarray",
166-
]
158+
deps = [Requirement(v).name for v in importlib.metadata.requires("pygmt")]
167159

168160
print("PyGMT information:", file=file)
169161
print(f" version: {__version__}", file=file)

0 commit comments

Comments
 (0)