diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index 976d080ccfa..7fc228f58a2 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -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' diff --git a/.github/workflows/ci_tests_legacy.yaml b/.github/workflows/ci_tests_legacy.yaml index 239a6fd5116..99e961ed181 100644 --- a/.github/workflows/ci_tests_legacy.yaml +++ b/.github/workflows/ci_tests_legacy.yaml @@ -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 diff --git a/environment.yml b/environment.yml index 5ab8f6cb94b..bc4722dcf09 100644 --- a/environment.yml +++ b/environment.yml @@ -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 diff --git a/pygmt/conftest.py b/pygmt/conftest.py deleted file mode 100644 index ee491b7f8bc..00000000000 --- a/pygmt/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -conftest.py for pytest. -""" - -import numpy as np -from packaging.version import Version - -# TODO(NumPy>=2.0): Remove the conftest.py file. -# Address https://github.com/GenericMappingTools/pygmt/issues/2628. -if Version(np.__version__) >= Version("2.0.0.dev0+git20230726"): - np.set_printoptions(legacy="1.25") # type: ignore[arg-type] diff --git a/pygmt/datatypes/image.py b/pygmt/datatypes/image.py index 2d6012a152d..3978e50ac36 100644 --- a/pygmt/datatypes/image.py +++ b/pygmt/datatypes/image.py @@ -76,7 +76,7 @@ class _GMT_IMAGE(ctp.Structure): # noqa: N801 >>> data.shape (180, 360, 3) >>> data.min(), data.max() - (10, 255) + (np.uint8(10), np.uint8(255)) """ _fields_: ClassVar = [ @@ -145,7 +145,8 @@ 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 @@ -155,7 +156,7 @@ def to_xarray(self) -> xr.DataArray: >>> da.coords["x"] # doctest: +NORMALIZE_WHITESPACE 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: diff --git a/pygmt/tests/test_clib_to_numpy.py b/pygmt/tests/test_clib_to_numpy.py index 4c228f7b0e5..e04f732bb3d 100644 --- a/pygmt/tests/test_clib_to_numpy.py +++ b/pygmt/tests/test_clib_to_numpy.py @@ -3,7 +3,6 @@ """ import datetime -import sys import numpy as np import numpy.testing as npt @@ -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")], diff --git a/pyproject.toml b/pyproject.toml index 8dd8a656f01..8a03f58b1a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/requirements.txt b/requirements.txt index de229b8acb2..804519b48c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Required packages -numpy>=1.26 +numpy>=2.0 pandas>=2.2 -xarray>=2023.10 +xarray>=2024.5 packaging>=24.2