Skip to content

Commit

Permalink
Merge branch 'main' into pytest/mark-benchmark-part2
Browse files Browse the repository at this point in the history
  • Loading branch information
weiji14 committed Jan 4, 2024
2 parents eef9dc8 + 03f66b5 commit 4c1f1e9
Show file tree
Hide file tree
Showing 107 changed files with 690 additions and 644 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
echo $CONDA/bin >> $GITHUB_PATH
conda install --solver=libmamba gmt=6.4.0 python=3.12 \
numpy pandas xarray netCDF4 packaging \
geopandas pyarrow pytest pytest-benchmark pytest-mpl
geopandas pyarrow pytest pytest-mpl
python -m pip install -U pytest-codspeed setuptools
# Download cached remote files (artifacts) from GitHub
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/cache_data.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Cache GMT remote data files and uploads as artifacts
# Cache GMT remote data files and upload as artifacts
#
# This workflow downloads data files needed by PyGMT tests/documentation from
# the GMT data server and uploads as workflow artifacts which can be accessed
# by other GitHub Actions workflows.
#
# It is scheduled to run every Sunday at 12:00 (UTC). If new remote files are
# needed urgently, maintainers can manually uncomment the 'pull_request:' line
# below to refresh the cache.
# needed urgently, maintainers can update the workflow file or
# 'pygmt/helpers/caching.py' file to refresh the cache.
#
name: Cache data

on:
# Uncomment the 'pull_request' line below to manually re-cache data artifacts
# pull_request:
pull_request:
# Make any changes to the following files to refresh the cache
paths:
- 'pygmt/helpers/caching.py'
- '.github/workflows/cache_data.yaml'
# Schedule runs on 12 noon every Sunday
schedule:
- cron: '0 12 * * 0'
Expand Down Expand Up @@ -61,7 +64,7 @@ jobs:
# Download remote files
- name: Download remote data
run: |
python -c "from pygmt.helpers.testing import download_test_data; download_test_data()"
python -c "from pygmt.helpers.caching import cache_data; cache_data()"
# Upload the downloaded files as artifacts to GitHub
- name: Upload artifacts to GitHub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
channels:
- conda-forge
- nodefaults
cache-downloads: true
cache-downloads: false
cache-environment: true
create-args: >-
python=3.12
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
channels:
- conda-forge
- nodefaults
cache-downloads: true
cache-downloads: false
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}${{ matrix.optional-packages }}
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/ci_tests_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,22 @@ jobs:
# fetch all history so that setuptools-scm works
fetch-depth: 0

# Generate token from GenericMappingTools bot
- name: Generate token from GenericMappingTools bot
uses: tibdex/github-app-token@v2
if: github.event_name == 'repository_dispatch'
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

# Checkout the pull request branch
- name: Checkout
uses: actions/[email protected]
if: github.event_name == 'repository_dispatch'
with:
token: ${{ steps.generate-token.outputs.token }}
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# fetch all history so that setuptools-scm works
fetch-depth: 0

- name: Show job URL
uses: peter-evans/[email protected]
if: github.event_name == 'repository_dispatch' && (matrix.os == 'ubuntu-latest')
if: github.event_name == 'repository_dispatch' && runner.os == 'Linux'
with:
token: ${{ steps.generate-token.outputs.token }}
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Expand All @@ -95,7 +86,7 @@ jobs:
channels:
- conda-forge
- nodefaults
cache-downloads: true
cache-downloads: false
cache-environment: true
create-args: >-
python=3.12
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_tests_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
channels:
- conda-forge
- nodefaults
cache-downloads: true
cache-downloads: false
cache-environment: true
create-args: >-
python=3.9
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# Install formatting tools
- name: Install formatting tools
run: |
python -m pip install docformatter ruff
python -m pip install ruff
python -m pip list
sudo apt-get install dos2unix
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ jobs:
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
# Generate token from GenericMappingTools bot
- uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ steps.generate-token.outputs.token }}
token: ${{ secrets.GITHUB_TOKEN }}
commands: |
format
test-gmt-dev
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ jobs:

- name: Install packages
run: |
python -m pip install docformatter ruff
python -m pip install ruff
python -m pip list
sudo apt-get install dos2unix
- name: Formatting check (docformatter, ruff)
- name: Formatting check (ruff)
run: make check

- name: Ensure files use UNIX line breaks and have 644 permission
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017-2023 The PyGMT Developers
Copyright (c) 2017-2024 The PyGMT Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ help:
@echo " fulltest run the test suite (including all doctests)"
@echo " doctest run the doctests only"
@echo " test_no_images run the test suite (including all doctests) but skip image comparisons"
@echo " format run docformatter and ruff to automatically format the code"
@echo " check run code style and quality checks (docformatter and ruff)"
@echo " format run ruff to automatically format the code"
@echo " check run ruff to check code style and quality"
@echo " codespell run codespell to check common misspellings"
@echo " typecheck run mypy for static type check"
@echo " clean clean up build and generated files"
Expand Down Expand Up @@ -60,12 +60,10 @@ test_no_images: PYTEST_ARGS=-o addopts="--verbose --durations=0 --durations-min=
test_no_images: _runtest

format:
docformatter --in-place $(FORMAT_FILES)
ruff check --fix $(FORMAT_FILES)
ruff format $(FORMAT_FILES)

check:
docformatter --check $(FORMAT_FILES)
ruff check $(FORMAT_FILES)
ruff format --check $(FORMAT_FILES)

Expand Down
16 changes: 6 additions & 10 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ arguments and return values.

While the maximum line length for code is automatically set by ruff, docstrings
must be formatted manually. To play nicely with Jupyter and IPython, **keep docstrings
limited to 79 characters** per line.
limited to 88 characters** per line.

### Standards for Example Code

Expand Down Expand Up @@ -471,14 +471,10 @@ code, be sure to follow the general guidelines in the

### Code Style

We use some tools to format the code so we don't have to think about it:

- [docformatter](https://github.com/myint/docformatter)
- [ruff](https://docs.astral.sh/ruff)

These tools loosely follow the [PEP8](http://pep8.org) guide but with a few
differences. Regardless, you won't have to worry about formatting the code yourself.
Before committing, run it to automatically format your code:
We use the [ruff](https://docs.astral.sh/ruff) tool to format the code, so we
don't have to think about it. It loosely follow the [PEP8](http://pep8.org) guide
but with a few differences. Regardless, you won't have to worry about formatting
the code yourself. Before committing, run it to automatically format your code:

```bash
make format
Expand Down Expand Up @@ -511,7 +507,7 @@ The [`Makefile`](https://github.com/GenericMappingTools/pygmt/blob/main/Makefile
contains rules for running the linter checks:

```bash
make check # Runs docformatter and ruff (in check mode)
make check # Runs ruff in check mode
```

### Testing your Code
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies:
- pip
# Dev dependencies (style checks)
- codespell
- docformatter>=1.7.2
- ruff>=0.1.9
# Dev dependencies (unit testing)
- matplotlib
Expand Down
3 changes: 3 additions & 0 deletions examples/gallery/3d_plots/grdview_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# Define an interesting function of two variables, see:
# https://en.wikipedia.org/wiki/Ackley_function
def ackley(x, y):
"""
Ackley function.
"""
return (
-20 * np.exp(-0.2 * np.sqrt(0.5 * (x**2 + y**2)))
- np.exp(0.5 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y)))
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/images/grdgradient_shading.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
panel=True,
)

fig.colorbar(position="JBC+w10c/0.25c+h", frame="a2000f500+lElevation (m)")
fig.colorbar(position="JBC+w10c/0.25c+h", frame="xa2000f500+lElevation (m)")

fig.show()
4 changes: 1 addition & 3 deletions examples/gallery/lines/vector_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
The :meth:`pygmt.Figure.plot` method can plot Cartesian, circular, and
geographic vectors. The ``style`` parameter controls vector attributes.
See also
:doc:`Vector attributes example </gallery/lines/vector_heads_tails>`.
See also :doc:`Vector attributes example </gallery/lines/vector_heads_tails>`.
"""

# %%
Expand Down
8 changes: 6 additions & 2 deletions examples/tutorials/advanced/working_with_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
)


# Define a function for plotting the single slices
@pn.depends(central_lon=slider_lon)
def view(central_lon):
"""
Define a function for plotting the single slices.
"""
# Create a new instance or object of the pygmt.Figure() class
fig = pygmt.Figure()
fig.coast(
Expand Down Expand Up @@ -112,9 +114,11 @@ def view(central_lon):
)


# Define a function for plotting the single slices
@pn.depends(central_lon=slider_lon)
def view(central_lon):
"""
Define a function for plotting the single slices.
"""
# Create a new instance or object of the pygmt.Figure() class
fig = pygmt.Figure()
# Set up a colormap for the elevation in meters
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/basics/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
style="cc",
pen="black",
)
fig.colorbar(frame="af+lDepth (km)")
fig.colorbar(frame="xaf+lDepth (km)")
fig.show()

# sphinx_gallery_thumbnail_number = 3
13 changes: 6 additions & 7 deletions pygmt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
PyGMT is a library for processing geospatial and geophysical data and making
publication-quality maps and figures. It provides a Pythonic interface for the
Generic Mapping Tools (GMT), a command-line program widely used across the
Earth, Ocean, and Planetary sciences and beyond. Besides making GMT more
accessible to new users, PyGMT aims to provide integration with the PyData
ecosystem as well as support for rich display in Jupyter notebooks.
publication-quality maps and figures. It provides a Pythonic interface for the Generic
Mapping Tools (GMT), a command-line program widely used across the Earth, Ocean, and
Planetary sciences and beyond. Besides making GMT more accessible to new users, PyGMT
aims to provide integration with the PyData ecosystem as well as support for rich
display in Jupyter notebooks.
Main Features
-------------
Expand Down Expand Up @@ -93,8 +93,7 @@ def print_clib_info(file=sys.stdout):

def show_versions(file=sys.stdout):
"""
Print various dependency versions which are useful when submitting bug
reports.
Print various dependency versions which are useful when submitting bug reports.
This includes information about:
Expand Down
3 changes: 1 addition & 2 deletions pygmt/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def registration(self, value):
@property
def gtype(self):
"""
Coordinate system type of the grid, either 0 (Cartesian) or 1
(Geographic).
Coordinate system type of the grid, either 0 (Cartesian) or 1 (Geographic).
"""
return self._gtype

Expand Down
4 changes: 2 additions & 2 deletions pygmt/clib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Low-level wrapper for the GMT C API.
The pygmt.clib.Session class wraps the GMT C shared library (libgmt) with a
Pythonic interface. Access to the C library is done through ctypes.
The pygmt.clib.Session class wraps the GMT C shared library (libgmt) with a Pythonic
interface. Access to the C library is done through ctypes.
"""

from pygmt.clib.session import Session
Expand Down
3 changes: 1 addition & 2 deletions pygmt/clib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ def dataarray_to_matrix(grid):

def vectors_to_arrays(vectors):
"""
Convert 1-D vectors (lists, arrays, or pandas.Series) to C contiguous 1-D
arrays.
Convert 1-D vectors (lists, arrays, or pandas.Series) to C contiguous 1-D arrays.
Arrays must be in C contiguous order for us to pass their memory pointers
to GMT. If any are not, convert them to C order (which requires copying the
Expand Down
4 changes: 2 additions & 2 deletions pygmt/clib/loading.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Utility functions to load libgmt as ctypes.CDLL.
The path to the shared library can be found automatically by ctypes or set
through the GMT_LIBRARY_PATH environment variable.
The path to the shared library can be found automatically by ctypes or set through the
GMT_LIBRARY_PATH environment variable.
"""
import ctypes
import os
Expand Down
Loading

0 comments on commit 4c1f1e9

Please sign in to comment.