Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ jobs:
include:
# Python 3.11 + core packages (minimum supported versions) + optional packages (minimum supported versions if any)
- python-version: '3.11'
numpy-version: '1.26'
numpy-version: '2.0'
pandas-version: '=2.2'
xarray-version: '=2023.10'
xarray-version: '=2024.5'
optional-packages: ' contextily geopandas ipython pyarrow-core rioxarray netCDF4 sphinx-gallery'
# Python 3.13 + core packages (latest versions) + optional packages
- python-version: '3.13'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_tests_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ jobs:
python=3.11
gmt=${{ matrix.gmt_version }}
ghostscript
numpy=1.26
numpy=2.0
pandas=2.2
xarray=2023.10
xarray=2024.5
packaging=24.2
contextily=1.5
geopandas=1.0
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ dependencies:
# Required dependencies
- gmt=6.6.0
- ghostscript=10.06.0
- numpy>=1.26
- numpy>=2.0
- pandas>=2.2
- xarray>=2023.10
- xarray>=2024.5
- packaging>=24.2
# Optional dependencies
- contextily>=1.5
Expand Down
11 changes: 0 additions & 11 deletions pygmt/conftest.py

This file was deleted.

10 changes: 5 additions & 5 deletions pygmt/datasets/tile_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def load_tile_map(
... )
>>> raster.sizes
Frozen({'band': 3, 'y': 256, 'x': 512})
>>> raster.coords # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
>>> raster.coords
Coordinates:
* band (band) uint8... 1 2 3
* y (y) float64... -7.081e-10 -7.858e+04 ... -1.996e+07 -2.004e+07
* x (x) float64... -2.004e+07 -1.996e+07 ... 1.996e+07 2.004e+07
spatial_ref int... 0
* band (band) uint8 3B 1 2 3
* y (y) float64 2kB -7.081e-10 -7.858e+04 ... -1.996e+07 -2.004e+07
* x (x) float64 4kB -2.004e+07 -1.996e+07 ... 1.996e+07 2.004e+07
spatial_ref int64 8B 0
>>> # CRS is set only if rioxarray is available
>>> if hasattr(raster, "rio"):
... raster.rio.crs.to_string()
Expand Down
22 changes: 11 additions & 11 deletions pygmt/datatypes/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def to_xarray(self) -> xr.DataArray:
... grid = lib.read_virtualfile(voutgrd, kind="grid")
... # Convert to xarray.DataArray and use it later
... da = grid.contents.to_xarray()
>>> da # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
<xarray.DataArray 'z' (lat: 14, lon: 8)>...
>>> da
<xarray.DataArray 'z' (lat: 14, lon: 8)> Size: 448B
array([[347.5, 344.5, 386. , 640.5, 617. , 579. , 646.5, 671. ],
[383. , 284.5, 344.5, 394. , 491. , 556.5, 578.5, 618.5],
[373. , 367.5, 349. , 352.5, 419.5, 428. , 570. , 667.5],
Expand All @@ -132,32 +132,32 @@ def to_xarray(self) -> xr.DataArray:
[347.5, 331.5, 309. , 282. , 190. , 208. , 299.5, 348. ]],
dtype=float32)
Coordinates:
* lat (lat) float64... -23.5 -22.5 -21.5 -20.5 ... -12.5 -11.5 -10.5
* lon (lon) float64... -54.5 -53.5 -52.5 -51.5 -50.5 -49.5 -48.5 -47.5
* lat (lat) float64 112B -23.5 -22.5 -21.5 -20.5 ... -12.5 -11.5 -10.5
* lon (lon) float64 64B -54.5 -53.5 -52.5 -51.5 -50.5 -49.5 -48.5 -47.5
Attributes:
Conventions: CF-1.7
title: Produced by grdcut
history: grdcut @earth_relief_01d_p -R-55/-47/-24/-10 -Gstatic_ea...
description: Reduced by Gaussian Cartesian filtering (111.2 km fullwi...
actual_range: [190. 981.]
long_name: elevation (m)
>>> da.coords["lon"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
<xarray.DataArray 'lon' (lon: 8)>...
>>> da.coords["lon"]
<xarray.DataArray 'lon' (lon: 8)> Size: 64B
array([-54.5, -53.5, -52.5, -51.5, -50.5, -49.5, -48.5, -47.5])
Coordinates:
* lon (lon) float64... -54.5 -53.5 -52.5 -51.5 -50.5 -49.5 -48.5 -47.5
* lon (lon) float64 64B -54.5 -53.5 -52.5 -51.5 -50.5 -49.5 -48.5 -47.5
Attributes:
long_name: longitude
units: degrees_east
standard_name: longitude
axis: X
actual_range: [-55. -47.]
>>> da.coords["lat"] # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
<xarray.DataArray 'lat' (lat: 14)>...
>>> da.coords["lat"]
<xarray.DataArray 'lat' (lat: 14)> Size: 112B
array([-23.5, -22.5, -21.5, -20.5, -19.5, -18.5, -17.5, -16.5, -15.5, -14.5,
-13.5, -12.5, -11.5, -10.5])
-13.5, -12.5, -11.5, -10.5])
Coordinates:
* lat (lat) float64... -23.5 -22.5 -21.5 -20.5 ... -12.5 -11.5 -10.5
* lat (lat) float64 112B -23.5 -22.5 -21.5 -20.5 ... -12.5 -11.5 -10.5
Attributes:
long_name: latitude
units: degrees_north
Expand Down
17 changes: 9 additions & 8 deletions pygmt/datatypes/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ class _GMT_IMAGE(ctp.Structure): # noqa: N801
[2, 2, 2, 2]
b'BRPa' 0.5
1 0
>>> x # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
>>> x
array([-179.5, -178.5, ..., 178.5, 179.5])
>>> y # doctest: +NORMALIZE_WHITESPACE, +ELLIPSIS
>>> y
array([ 89.5, 88.5, ..., -88.5, -89.5])
>>> data.dtype
dtype('uint8')
>>> data.shape
(180, 360, 3)
>>> data.min(), data.max()
(10, 255)
(np.uint8(10), np.uint8(255))
"""

_fields_: ClassVar = [
Expand Down Expand Up @@ -121,7 +121,7 @@ def to_xarray(self) -> xr.DataArray:
... image = lib.read_virtualfile(voutimg, kind="image")
... # Convert to xarray.DataArray and use it later
... da = image.contents.to_xarray()
>>> da # doctest: +NORMALIZE_WHITESPACE
>>> da
<xarray.DataArray 'z' (band: 3, y: 180, x: 360)> Size: 194kB
array([[[ 10, 10, 10, ..., 10, 10, 10],
[ 10, 10, 10, ..., 10, 10, 10],
Expand All @@ -145,24 +145,25 @@ def to_xarray(self) -> xr.DataArray:
...,
[177, 179, 179, ..., 178, 177, 177],
[185, 187, 187, ..., 187, 186, 185],
[189, 191, 191, ..., 191, 191, 189]]], dtype=uint8)
[189, 191, 191, ..., 191, 191, 189]]],
shape=(3, 180, 360), dtype=uint8)
Coordinates:
* band (band) uint8 3B 1 2 3
* y (y) float64 1kB 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
* x (x) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
Attributes:
long_name: z

>>> da.coords["x"] # doctest: +NORMALIZE_WHITESPACE
>>> da.coords["x"]
<xarray.DataArray 'x' (x: 360)> Size: 3kB
array([-179.5, -178.5, -177.5, ..., 177.5, 178.5, 179.5])
array([-179.5, -178.5, -177.5, ..., 177.5, 178.5, 179.5], shape=(360,))
Coordinates:
* x (x) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
Attributes:
long_name: x
axis: X
actual_range: [-180. 180.]
>>> da.coords["y"] # doctest: +NORMALIZE_WHITESPACE
>>> da.coords["y"]
<xarray.DataArray 'y' (y: 180)> Size: 1kB
array([ 89.5, 88.5, 87.5, 86.5, ..., -87.5, -88.5, -89.5])
Coordinates:
Expand Down
4 changes: 1 addition & 3 deletions pygmt/helpers/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,7 @@ def use_alias(**aliases):
R = bla J = meh
>>> my_module(region="bla", projection="meh")
R = bla J = meh
>>> my_module(
... region="bla", projection="meh", J="bla"
... ) # doctest: +NORMALIZE_WHITESPACE
>>> my_module(region="bla", projection="meh", J="bla")
Traceback (most recent call last):
...
pygmt.exceptions.GMTInvalidInput:
Expand Down
10 changes: 1 addition & 9 deletions pygmt/tests/test_clib_to_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import datetime
import sys

import numpy as np
import numpy.testing as npt
Expand Down Expand Up @@ -52,14 +51,7 @@ def _check_result(result, expected_dtype):
@pytest.mark.parametrize(
("data", "expected_dtype"),
[
# TODO(NumPy>=2.0): Remove the if-else statement after NumPy>=2.0.
pytest.param(
[1, 2, 3],
np.int32
if sys.platform == "win32" and Version(np.__version__) < Version("2.0")
else np.int64,
id="int",
),
pytest.param([1, 2, 3], np.int64, id="int"),
pytest.param([1.0, 2.0, 3.0], np.float64, id="float"),
pytest.param(
[complex(+1), complex(-2j), complex("-Infinity+NaNj")],
Expand Down
16 changes: 8 additions & 8 deletions pygmt/xarray/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class GMTBackendEntrypoint(BackendEntrypoint):
>>> da_grid = xr.open_dataarray(
... "@static_earth_relief.nc", engine="gmt", raster_kind="grid"
... )
>>> da_grid # doctest: +NORMALIZE_WHITESPACE
>>> da_grid
<xarray.DataArray 'z' (lat: 14, lon: 8)> Size: 448B
[112 values with dtype=float32]
Coordinates:
* lat (lat) float64 112B -23.5 -22.5 -21.5 -20.5 ... -12.5 -11.5 -10.5
* lon (lon) float64 64B -54.5 -53.5 -52.5 -51.5 -50.5 -49.5 -48.5 -47.5
Attributes:...
Attributes:
Conventions: CF-1.7
title: Produced by grdcut
history: grdcut @earth_relief_01d_p -R-55/-47/-24/-10 -Gstatic_eart...
Expand All @@ -69,14 +69,14 @@ class GMTBackendEntrypoint(BackendEntrypoint):
>>> da_image = xr.open_dataarray(
... "@earth_night_01d", engine="gmt", raster_kind="image"
... )
>>> da_image # doctest: +NORMALIZE_WHITESPACE
>>> da_image
<xarray.DataArray 'z' (band: 3, y: 180, x: 360)> Size: 194kB
[194400 values with dtype=uint8]
Coordinates:
* band (band) uint8... 1 2 3
* y (y) float64... 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
* x (x) float64... -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
Attributes:...
* band (band) uint8 3B 1 2 3
* y (y) float64 1kB 89.5 88.5 87.5 86.5 ... -86.5 -87.5 -88.5 -89.5
* x (x) float64 3kB -179.5 -178.5 -177.5 -176.5 ... 177.5 178.5 179.5
Attributes:
long_name: z

Load a single-band netCDF file using ``raster_kind="grid"`` over a bounding box
Expand All @@ -95,7 +95,7 @@ class GMTBackendEntrypoint(BackendEntrypoint):
Coordinates:
* lat (lat) float64 104B 32.0 32.08 32.17 32.25 ... 32.83 32.92 33.0
* lon (lon) float64 200B -64.0 -63.92 -63.83 ... -62.17 -62.08 -62.0
Attributes:...
Attributes:
Conventions: CF-1.7
title: ETOPO5 global topography
history: grdreformat -fg bermuda.grd bermuda.nc=ns
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
dependencies = [
"numpy>=1.26",
"numpy>=2.0",
"pandas>=2.2",
"xarray>=2023.10",
"xarray>=2024.5",
"packaging>=24.2",
]
dynamic = ["version"]
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Required packages
numpy>=1.26
numpy>=2.0
pandas>=2.2
xarray>=2023.10
xarray>=2024.5
packaging>=24.2
Loading