Skip to content

Commit d52f2c8

Browse files
author
Meghan Jones
committed
Merge branch 'main' into update-common-strings
2 parents 401bda2 + f7d5526 commit d52f2c8

File tree

8 files changed

+81
-27
lines changed

8 files changed

+81
-27
lines changed

.github/workflows/cache_data.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ jobs:
2424
# fecth all history so that setuptools-scm works
2525
fetch-depth: 0
2626

27-
# Setup Miniconda
28-
- name: Setup Miniconda
27+
# Install Mambaforge with conda-forge dependencies
28+
- name: Setup Mambaforge
2929
uses: conda-incubator/setup-miniconda@v2.1.1
3030
with:
31-
channels: conda-forge
32-
miniconda-version: "latest"
31+
channels: conda-forge,nodefaults
32+
channel-priority: strict
33+
miniforge-version: latest
34+
miniforge-variant: Mambaforge
35+
mamba-version: "*"
36+
use-mamba: true
3337

3438
# Install GMT and other required dependencies from conda-forge
3539
- name: Install dependencies
3640
run: |
37-
conda install gmt=6.2.0 \
41+
mamba install gmt=6.2.0 \
3842
numpy pandas xarray netCDF4 packaging matplotlib
3943
4044
# Install the package that we want to test

.github/workflows/ci_docs.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,29 @@ jobs:
5454
# fecth all history so that setuptools-scm works
5555
fetch-depth: 0
5656

57-
# Setup Miniconda
58-
- name: Setup Miniconda
57+
# Install Mambaforge with conda-forge dependencies
58+
- name: Setup Mambaforge
5959
uses: conda-incubator/setup-miniconda@v2.1.1
6060
with:
6161
activate-environment: pygmt
6262
python-version: ${{ matrix.python-version }}
63-
channels: conda-forge
64-
miniconda-version: "latest"
63+
channels: conda-forge,nodefaults
64+
channel-priority: strict
65+
miniforge-version: latest
66+
miniforge-variant: Mambaforge
67+
mamba-version: "*"
68+
use-mamba: true
6569

6670
# Install GMT and other required dependencies from conda-forge
6771
- name: Install dependencies
6872
run: |
69-
conda install gmt=6.2.0 numpy pandas xarray netCDF4 packaging \
73+
mamba install gmt=6.2.0 numpy pandas xarray netCDF4 packaging \
7074
ipython make myst-parser geopandas \
7175
sphinx sphinx-copybutton sphinx-gallery sphinx_rtd_theme
7276
7377
# Show installed pkg information for postmortem diagnostic
7478
- name: List installed packages
75-
run: conda list
79+
run: mamba list
7680

7781
# Download cached remote files (artifacts) from GitHub
7882
- name: Download remote data from GitHub

.github/workflows/ci_tests.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,32 @@ jobs:
7777
# fecth all history so that setuptools-scm works
7878
fetch-depth: 0
7979

80-
# Setup Miniconda
81-
- name: Setup Miniconda
80+
# Install Mambaforge with conda-forge dependencies
81+
- name: Setup Mambaforge
8282
uses: conda-incubator/setup-miniconda@v2.1.1
8383
with:
8484
activate-environment: pygmt
8585
python-version: ${{ matrix.python-version }}
86-
channels: conda-forge
87-
miniconda-version: "latest"
86+
channels: conda-forge,nodefaults
87+
channel-priority: strict
88+
miniforge-version: latest
89+
miniforge-variant: Mambaforge
90+
mamba-version: "*"
91+
use-mamba: true
8892

8993
# Install GMT and other required dependencies from conda-forge
9094
- name: Install dependencies
9195
run: |
92-
conda install gmt=6.2.0 numpy=${{ matrix.numpy-version }} \
96+
mamba install gmt=6.2.0 numpy=${{ matrix.numpy-version }} \
9397
pandas xarray netCDF4 packaging \
9498
${{ matrix.optional-packages }} \
95-
codecov coverage[toml] dvc ipython make \
99+
coverage[toml] dvc ipython make \
96100
pytest-cov pytest-mpl pytest>=6.0 \
97101
sphinx-gallery
98102
99103
# Show installed pkg information for postmortem diagnostic
100104
- name: List installed packages
101-
run: conda list
105+
run: mamba list
102106

103107
# Download cached remote files (artifacts) from GitHub
104108
- name: Download remote data from GitHub

.github/workflows/ci_tests_dev.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,23 @@ jobs:
7171
# fecth all history so that setuptools-scm works
7272
fetch-depth: 0
7373

74-
# Setup Miniconda
75-
- name: Setup Miniconda
74+
# Install Mambaforge with conda-forge dependencies
75+
- name: Setup Mambaforge
7676
uses: conda-incubator/setup-miniconda@v2.1.1
7777
with:
7878
activate-environment: pygmt
7979
python-version: ${{ matrix.python-version }}
80-
channels: conda-forge
81-
miniconda-version: "latest"
80+
channels: conda-forge,nodefaults
81+
channel-priority: strict
82+
miniforge-version: latest
83+
miniforge-variant: Mambaforge
84+
mamba-version: "*"
85+
use-mamba: true
8286

8387
# Install dependencies from conda-forge
8488
- name: Install dependencies
8589
run: |
86-
conda install ninja cmake libblas libcblas liblapack fftw gdal geopandas \
90+
mamba install ninja cmake libblas libcblas liblapack fftw gdal geopandas \
8791
ghostscript libnetcdf hdf5 zlib curl pcre make dvc
8892
pip install --pre numpy pandas xarray netCDF4 packaging \
8993
ipython pytest-cov pytest-mpl pytest>=6.0 sphinx-gallery \
@@ -98,7 +102,7 @@ jobs:
98102
if: runner.os != 'Windows'
99103

100104
- name: Install GMT dev version from conda-forge (Windows)
101-
run: conda install -c conda-forge/label/dev gmt
105+
run: mamba install -c conda-forge/label/dev gmt=6.3
102106
if: runner.os == 'Windows'
103107

104108
# Download cached remote files (artifacts) from GitHub

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ PyGMT
1616
.. image:: https://github.com/GenericMappingTools/pygmt/workflows/GMT%20Dev%20Tests/badge.svg
1717
:alt: GitHub Actions GMT Dev Tests status
1818
:target: https://github.com/GenericMappingTools/pygmt/actions/workflows/ci_tests_dev.yaml
19-
.. image:: https://img.shields.io/codecov/c/github/GenericMappingTools/pygmt/main.svg?style=flat-square
19+
.. image:: https://codecov.io/gh/GenericMappingTools/pygmt/branch/main/graph/badge.svg?token=78Fu4EWstx
2020
:alt: Test coverage status
21-
:target: https://codecov.io/gh/GenericMappingTools/pygmt
21+
:target: https://app.codecov.io/gh/GenericMappingTools/pygmt
2222
.. image:: https://img.shields.io/pypi/pyversions/pygmt.svg?style=flat-square
2323
:alt: Compatible Python versions.
2424
:target: https://pypi.python.org/pypi/pygmt

doc/maintenance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ There are 11 configuration files located in `.github/workflows`:
8787
Python/NumPy versions
8888
- Latest Python/NumPy versions + optional packages (e.g. GeoPandas)
8989

90+
This workflow is also responsible for uploading test coverage reports stored
91+
in `.coverage.xml` to https://app.codecov.io/gh/GenericMappingTools/pygmt
92+
via the [Codecov GitHub Action](https://github.com/codecov/codecov-action).
93+
More codecov related configurations are stored in `.github/codecov.yml`.
94+
9095
3. `ci_docs.yml` (Build documentation on Linux/macOS/Windows)
9196

9297
This is run on every commit to the *main* and Pull Request branches.

environment.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dependencies:
1616
# Development dependencies
1717
- black
1818
- blackdoc
19-
- codecov
2019
- coverage[toml]
2120
- docformatter
2221
- dvc

pygmt/tests/test_io.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
Tests for input/output (I/O) utilities.
3+
"""
4+
import numpy as np
5+
import pytest
6+
import xarray as xr
7+
from pygmt.helpers import GMTTempFile
8+
from pygmt.io import load_dataarray
9+
10+
11+
def test_io_load_dataarray():
12+
"""
13+
Check that load_dataarray works to read a NetCDF grid with
14+
GMTDataArrayAccessor information loaded.
15+
"""
16+
with GMTTempFile(suffix=".nc") as tmpfile:
17+
grid = xr.DataArray(
18+
data=np.random.rand(2, 2), coords=[[0.1, 0.2], [0.3, 0.4]], dims=("x", "y")
19+
)
20+
grid.to_netcdf(tmpfile.name)
21+
dataarray = load_dataarray(tmpfile.name)
22+
assert dataarray.gmt.gtype == 0 # Cartesian grid
23+
assert dataarray.gmt.registration == 1 # Pixel registration
24+
# this would fail if we used xr.open_dataarray instead of
25+
# load_dataarray
26+
dataarray.to_netcdf(tmpfile.name)
27+
28+
29+
def test_io_load_dataarray_cache():
30+
"""
31+
Check that load_dataarray fails when the cache argument is used.
32+
"""
33+
with pytest.raises(TypeError):
34+
_ = load_dataarray("somefile.nc", cache=True)

0 commit comments

Comments
 (0)