Skip to content

Commit

Permalink
Merge pull request #20 from ajdawson/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
ajdawson authored Oct 7, 2023
2 parents c0ae1f9 + 99293f6 commit 36a5199
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 151 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "Bot"
49 changes: 49 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Documentation

on:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:
build-docs:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: DOCS
init-shell: bash
create-args: >-
python=3 pip iris numpy sphinx sphinx-rtd-theme --channel conda-forge
- name: Install gridfill
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Build documentation
shell: bash -l {0}
run: |
set -e
micromamba activate DOCS
pushd doc
make clean html linkcheck
popd
- name: Deploy
if: success() && github.event_name == 'release'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: doc/_build/html
37 changes: 37 additions & 0 deletions .github/workflows/tests_iris.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests (with iris)

on:
pull_request:
push:
branches: [main]

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Setup Micromamba Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
environment-name: TEST
init-shell: bash
create-args: >-
python=${{ matrix.python-version }} pip pytest iris numpy --channel conda-forge
- name: Install gridfill
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Tests
shell: bash -l {0}
run: |
python -m pytest -vrsx gridfill/tests
37 changes: 37 additions & 0 deletions .github/workflows/tests_numpy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests (numpy only)

on:
pull_request:
push:
branches: [main]

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Setup Micromamba Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
environment-name: TEST
init-shell: bash
create-args: >-
python=${{ matrix.python-version }} pip pytest numpy --channel conda-forge
- name: Install gridfill
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall
- name: Tests
shell: bash -l {0}
run: |
python -m pytest -vrsx gridfill/tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dist
## Ignore build output
gridfill/_gridfill.c
*.so
gridfill/_version.py
53 changes: 0 additions & 53 deletions .travis.yml

This file was deleted.

7 changes: 3 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
include COPYING
include README.rst
recursive-include lib *.py
recursive-include lib *.pyx
include COPYING README.rst
recursive-include gridfill *.py *.pyx *.npy
recursive-include doc *.py *.rst Makefile
20 changes: 18 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ gridfill can also operate on `iris` cubes, which requires the iris_
package to be installed.


.. _conda: http://conda.pydata.org
Developers
----------

For development the pytest package is required in order to run tests. In order
to run all tests you should also install iris_.

Tests can be run in-place but you must first compile the extension module::

python setup.py build_ext --inplace
python -m pytest

Tests can also be run against the installed version::

python -m pytest --pyargs gridfill.tests


.. _conda: https://docs.conda.io/en/latest/
.. _Github: https://github.com/ajdawson/gridfill
.. _iris: http://scitools.org.uk/iris
.. _iris: https://scitools-iris.readthedocs.io/en/stable/
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down Expand Up @@ -147,7 +147,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = []

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -299,5 +299,5 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'numpy': ('http://docs.scipy.org/doc/numpy', None),
'iris': ('http://scitools.org.uk/iris/docs/latest', None),
'iris': ('https://scitools-iris.readthedocs.io/en/latest/', None),
}
16 changes: 8 additions & 8 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gridfill
Gridfill is a Python package for filling in missing values in gridded data.
Missing values are filled by solving Poisson's equation using an iterative relaxation scheme at the missing values, resulting in a smooth filling.

The core package runs on Python 2 or 3, on Linux and OSX (maybe on Windows too), and requires numpy_.
The core package runs on Python 3, on Linux and OSX (maybe on Windows too), and requires numpy_.
Gridfill has an optional interface for working with iris_ cubes.


Expand Down Expand Up @@ -64,10 +64,10 @@ Bug reports and feature requests should be made using the repository issues_ pag
Pull requests for new features and bug fixes are welcome!


.. _numpy: http://www.numpy.org
.. _iris: http://scitools.org.uk/iris
.. _conda: http://conda.pydata.org/docs/
.. _setuptools: https://pypi.python.org/pypi/setuptools
.. _cython: http://cython.org
.. _Github: http://github.com/ajdawson/gridfill
.. _issues: http://github.com/ajdawson/gridfill/issues
.. _numpy: https://numpy.org
.. _iris: https://scitools-iris.readthedocs.io/en/stable/
.. _conda: https://docs.conda.io/en/latest/
.. _setuptools: https://setuptools.pypa.io/en/latest/
.. _cython: https://cython.org
.. _Github: https://github.com/ajdawson/gridfill
.. _issues: https://github.com/ajdawson/gridfill/issues
7 changes: 4 additions & 3 deletions gridfill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

from .gridfill import fill, fill_cube


# Define a version string.
__version__ = '1.0.dev2'
try:
from ._version import __version__
except ImportError:
__version__ == "unknown"

# Define the objects to be imported by imports of the form:
# from gridfill import *
Expand Down
2 changes: 1 addition & 1 deletion gridfill/_gridfill.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cython: boundscheck=False, wraparound=False, initializedcheck=False
#cython: language_level=3, boundscheck=False, wraparound=False, initializedcheck=False
"""Fill missing values in grids using an iterative relaxation scheme."""
# Copyright (c) 2016 Andrew Dawson
#
Expand Down
17 changes: 11 additions & 6 deletions gridfill/tests/test_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# THE SOFTWARE.
import os

from nose.tools import raises
import pytest
import numpy as np
import numpy.ma as ma

Expand Down Expand Up @@ -72,12 +72,17 @@ def test_multi_grid(self):
cyclic=self.cyclic, verbose=False)
self.assert_array_almost_equal(filled, self.soln)

@raises(TypeError)
def test_not_masked(self):
filled, c = fill(self.grid.filled(fill_value=np.nan), self.eps,
relax=self.relax, itermax=self.itermax,
initzonal=self.initzonal, cyclic=self.cyclic,
verbose=False)
with pytest.raises(TypeError):
fill(
self.grid.filled(fill_value=np.nan),
self.eps,
relax=self.relax,
itermax=self.itermax,
initzonal=self.initzonal,
cyclic=self.cyclic,
verbose=False,
)

def assert_array_almost_equal(self, a, b):
np.testing.assert_array_almost_equal(a, b)
Expand Down
17 changes: 9 additions & 8 deletions gridfill/tests/test_fill_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
# THE SOFTWARE.
import warnings

from nose import SkipTest
from nose.tools import raises

import pytest
try:
import iris
import iris.coords
import iris.cube
except ImportError:
raise SkipTest('Cannot import iris, fill_cube() will not be tested')
pytest.skip('Cannot import iris, fill_cube() will not be tested', allow_module_level=True)
import numpy as np

from gridfill import fill_cube
Expand Down Expand Up @@ -83,11 +82,13 @@ def test_multi_grid_inplace(self):
assert not hasattr(filled.data, 'mask')
assert not hasattr(cube.data, 'mask')

@raises(TypeError)
def test_not_masked(self):
cube = self.cube.copy(data=self.cube.data.filled(fill_value=np.nan))
fill_cube(cube, self.eps, relax=self.relax, itermax=self.itermax,
initzonal=self.initzonal, verbose=False)
with pytest.raises(TypeError):
fill_cube(
cube, self.eps, relax=self.relax, itermax=self.itermax,
initzonal=self.initzonal, verbose=False
)

def test_not_converged_warning(self):
with warnings.catch_warnings(record=True) as w:
Expand Down
Loading

0 comments on commit 36a5199

Please sign in to comment.