Skip to content

Commit

Permalink
Merge pull request #703 from sadielbartholomew/drop-python-3.7
Browse files Browse the repository at this point in the history
Testing and CI tidying including adding Python 3.12 job
  • Loading branch information
sadielbartholomew authored Oct 25, 2023
2 parents 1668e0b + 1047712 commit 2d53ef6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/run-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
matrix:
# Skip older ubuntu-16.04 & macos-10.15 to save usage resource
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.9]
# Note: keep versions quoted as strings else 3.10 taken as 3.1, etc.
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

# Run on new and old(er) versions of the distros we support (Linux, Mac OS)
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -59,7 +60,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: 'latest'
miniconda-version: "latest"
activate-environment: cf-latest
python-version: ${{ matrix.python-version }}
channels: ncas, conda-forge
Expand Down Expand Up @@ -146,7 +147,7 @@ jobs:
# passing at least for that job, avoiding useless coverage reports.
uses: codecov/codecov-action@v3
if: |
matrix.os == 'ubuntu-latest' && matrix.python-version == 3.8
matrix.os == "ubuntu-latest" && matrix.python-version == "3.9"
with:
file: |
${{ github.workspace }}/main/cf/test/cf_coverage_reports/coverage.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-source-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8]
python-version: ["3.8"]
runs-on: ${{ matrix.os }}

# The sequence of tasks that will be executed as part of this job:
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: 'latest'
miniconda-version: "latest"
activate-environment: cf-latest
python-version: ${{ matrix.python-version }}
channels: ncas, conda-forge
Expand Down
2 changes: 1 addition & 1 deletion cf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
)

x = ", ".join(_requires)
_error0 = f"cf v{ __version__} requires the modules {x}. "
_error0 = f"cf v{__version__} requires the modules {x}. "

try:
import cfdm
Expand Down
2 changes: 1 addition & 1 deletion cf/read_write/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def read(
if info:
logger.info(
f"{org_len} input field{_plural(org_len)} aggregated into "
f"{n} field{ _plural(n)}"
f"{n} field{_plural(n)}"
) # pragma: no cover

# ----------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions cf/test/test_Field.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
try:
from scipy.ndimage import convolve1d

# In some cases we don't need SciPy directly, since it is required by code
# here which uses 'convolve1d' under-the-hood. Without it installed, get:
#
# NameError: name 'convolve1d' is not defined. Did you
# mean: 'cf_convolve1d'?

SCIPY_AVAILABLE = True
# not 'except ImportError' as that can hide nested errors, catch anything:
except Exception:
Expand Down Expand Up @@ -2330,6 +2336,9 @@ def test_Field_percentile(self):
# TODO: add loop to check get same shape and close enough data
# for every possible axis combo (see also test_Data_percentile).

@unittest.skipIf(
not SCIPY_AVAILABLE, "scipy must be installed for this test."
)
def test_Field_grad_xy(self):
f = cf.example_field(0)

Expand Down Expand Up @@ -2415,6 +2424,9 @@ def test_Field_grad_xy(self):
y.dimension_coordinate("X").standard_name, "longitude"
)

@unittest.skipIf(
not SCIPY_AVAILABLE, "scipy must be installed for this test."
)
def test_Field_laplacian_xy(self):
f = cf.example_field(0)

Expand Down
24 changes: 24 additions & 0 deletions cf/test/test_Maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,30 @@
import faulthandler
import unittest


SCIPY_AVAILABLE = False
try:
# We don't need SciPy directly in this test, it is only required by code
# here which uses 'convolve1d' under-the-hood. Without it installed, get:
#
# NameError: name 'convolve1d' is not defined. Did you
# mean: 'cf_convolve1d'?
import scipy

SCIPY_AVAILABLE = True
# not 'except ImportError' as that can hide nested errors, catch anything:
except Exception:
pass # test with this dependency will then be skipped by unittest

faulthandler.enable() # to debug seg faults and timeouts

import cf


class MathTest(unittest.TestCase):
@unittest.skipIf(
not SCIPY_AVAILABLE, "scipy must be installed for this test."
)
def test_curl_xy(self):
f = cf.example_field(0)

Expand Down Expand Up @@ -97,6 +115,9 @@ def test_curl_xy(self):
c.dimension_coordinate("X").standard_name, "longitude"
)

@unittest.skipIf(
not SCIPY_AVAILABLE, "scipy must be installed for this test."
)
def test_div_xy(self):
f = cf.example_field(0)

Expand Down Expand Up @@ -185,6 +206,9 @@ def test_div_xy(self):
d.dimension_coordinate("X").standard_name, "longitude"
)

@unittest.skipIf(
not SCIPY_AVAILABLE, "scipy must be installed for this test."
)
def test_differential_operators(self):
f = cf.example_field(0)

Expand Down

0 comments on commit 2d53ef6

Please sign in to comment.